*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="orapoarte_cont.vcx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_alegeperioada 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_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label6" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner6" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner7" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner10" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner11" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_spinner12" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkCuSold" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkAnalitic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Txt_analitic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label7" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_crsintervale
		*m: lansanalitic
		*p: ccont
		*p: ceactiv
		*p: ctip
		*p: ddata
		*p: gctip
		*p: lemitere		&& Calcul vechime fata de data emitere sau data scadenta
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		ccont = 
		ceactiv = 
		ctip = 
		ddata = 
		DoCreate = .T.
		gctip = .F.
		Height = 293
		lemitere = .F.
		Name = "frm_alegeperioada"
		Width = 271
		_memberdata = <VFPData>
			<memberdata name="lemitere" display="lEmitere"/>
		</VFPData>
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 288
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 86
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 19
		BUT_TERMIN1.Left = 240
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 17
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 252
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 132
	*</PropValue>

	ADD OBJECT '_label1' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 1", ;
		Left = 17, ;
		Name = "_label1", ;
		TabIndex = 20, ;
		Top = 105
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label2' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 2", ;
		Left = 17, ;
		Name = "_label2", ;
		TabIndex = 22, ;
		Top = 135
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label3' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 3", ;
		Left = 17, ;
		Name = "_label3", ;
		TabIndex = 23, ;
		Top = 165
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label4' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 4", ;
		Left = 17, ;
		Name = "_label4", ;
		TabIndex = 24, ;
		Top = 195
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label5' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 5 ", ;
		Left = 17, ;
		Name = "_label5", ;
		TabIndex = 25, ;
		Top = 225
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label6' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Interval 6", ;
		Left = 17, ;
		Name = "_label6", ;
		TabIndex = 26, ;
		Top = 255
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_label7' AS _label WITH ;
		BackStyle = 0, ;
		Caption = "Analitic", ;
		Left = 160, ;
		Name = "_label7", ;
		TabIndex = 21, ;
		Top = 62
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT '_spinner1' AS _spinner WITH ;
		ControlSource = "gnVechime1", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner1", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 4, ;
		Top = 100, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner10' AS _spinner WITH ;
		ControlSource = "gnVechime10", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner10", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 13, ;
		Top = 220, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner11' AS _spinner WITH ;
		ControlSource = "gnVechime11", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner11", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 14, ;
		Top = 250, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner12' AS _spinner WITH ;
		ControlSource = "gnVechime12", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner12", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 15, ;
		Top = 250, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner2' AS _spinner WITH ;
		ControlSource = "gnVechime2", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner2", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 5, ;
		Top = 100, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner3' AS _spinner WITH ;
		ControlSource = "gnVechime3", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner3", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 6, ;
		Top = 130, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner4' AS _spinner WITH ;
		ControlSource = "gnVechime4", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner4", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 7, ;
		Top = 130, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner5' AS _spinner WITH ;
		ControlSource = "gnVechime5", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner5", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 8, ;
		Top = 160, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner6' AS _spinner WITH ;
		ControlSource = "gnVechime6", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner6", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 9, ;
		Top = 160, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner7' AS _spinner WITH ;
		ControlSource = "gnVechime7", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner7", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 10, ;
		Top = 190, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner8' AS _spinner WITH ;
		ControlSource = "gnVechime8", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 185, ;
		Name = "_spinner8", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 11, ;
		Top = 190, ;
		Width = 69
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT '_spinner9' AS _spinner WITH ;
		ControlSource = "gnVechime9", ;
		Height = 24, ;
		InputMask = "99 999", ;
		KeyboardHighValue = 99999, ;
		KeyboardLowValue = 0, ;
		Left = 101, ;
		Name = "_spinner9", ;
		SpinnerHighValue = 99999.00, ;
		SpinnerLowValue =   0.00, ;
		TabIndex = 12, ;
		Top = 220, ;
		Width = 70
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

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

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

	ADD OBJECT 'chkAnalitic' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackColor = 255,255,255, ;
		Caption = "Grupare pe analitice", ;
		Height = 17, ;
		Left = 17, ;
		Name = "chkAnalitic", ;
		TabIndex = 2, ;
		Top = 62, ;
		Width = 129
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'chkCuSold' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackColor = 255,255,255, ;
		Caption = "Sold diferit de 0", ;
		Height = 17, ;
		Left = 17, ;
		Name = "chkCuSold", ;
		TabIndex = 1, ;
		Top = 36, ;
		Width = 103
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Txt_analitic' AS textbox WITH ;
		Height = 21, ;
		Left = 202, ;
		Name = "Txt_analitic", ;
		TabIndex = 3, ;
		Top = 60, ;
		Width = 50
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE do_crsintervale
		*!*	adaugare v 2.0.77
		
		*!* 11.08.2009
		*!* marius.mutu
		*!* NVL(dataact,TO_DATE('01011900','DDMMYYYY')) <= ?pdData in loc de dataact <= ?pdData
		*!* nu lua in considerare inregistrarile gresite din ireg_parteneri fara data (incasari neimperecheate)
		
		*!* 02.03.2011
		*!* marius.mutu
		*!* grupare pe analitice, filtrare dupa analitic
		*!* la furnizori si la alti se foloseste acelasi raport, clientii au coloana sold incert in plus
		
		*!* 07.06.2011
		*!* marius.mutu
		*!* selectia "" as acont din ireg_parteneri crea o coloana NULL cu lungime 0 in cursorul din foxpro si dadea eroare la selectia urmatoare pentru exportul in xls
		*!* s-a transformat in "    " as acont
		
		*!* 11.04.2013
		*!* marius.mutu
		*!* Furnizori, Alti - raport vechime dupa data scadenta sau dupa data emitere
		
		private pcCont
		Local lcAcont, lcConditieAcont, lcEmptyData, lcsql, llCuSold, llGrupareAnalitic, lnSucces
		*:Global gcExplicatie, gcRaport
		pcCont = alltrim(Thisform.cCont)
		
		llCuSold		  = This.chkCuSold.Value = 1
		llGrupareAnalitic = This.chkAnalitic.Value = 1
		lcAcont			  = Alltrim(This.txt_analitic.Value)
		lcConditieAcont	  = Iif(!Empty(m.lcAcont), [ and acont = '] + m.lcAcont + [' ], [])
		lcEmptyData		  = dtos(date() - 9000) && 25 de ani in urma 20
		
		
		Do Case
			Case Thisform.ctip = [C]
				gcExplicatie = [CLIENTI]
				lcsql = [Select a.id_part,b.denumire,a.acont, Sum(a.sold) As sold,] + ;
					[SUM(case when ?pdData Between NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime1 and NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime2 And ] + ;
					[a.incert = 0 and ?gnVechime1<>0 and ?gnVechime2<>0 then a.sold else 0.00 end) As rest_1,] + ;
					[SUM(case when ?pdData Between NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime3 and NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime4 And ] + ;
					[a.incert = 0 and ?gnVechime3<>0 and ?gnVechime4<>0 then a.sold else 0.00 end) As rest_2,] + ;
					[SUM(case when ?pdData Between NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime5 and NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime6 And ] + ;
					[a.incert = 0 and ?gnVechime5<>0 and ?gnVechime6<>0 then a.sold else 0.00 end) As rest_3,] + ;
					[SUM(case when ?pdData Between NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime7 and NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime8 And ] + ;
					[a.incert = 0 and ?gnVechime7<>0 and ?gnVechime8<>0 then a.sold else 0.00 end) As rest_4,] + ;
					[SUM(case when ?pdData Between NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime9 and NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime10 And ] + ;
					[a.incert = 0 and ?gnVechime9<>0 and ?gnVechime10<>0 then a.sold else 0.00 end) As rest_5,] + ;
					[SUM(case when ?pdData >= NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) + ?gnVechime11 And a.incert = 0 and ?gnVechime11<>0 and ?gnVechime12<>0 then ] + ;
					[a.sold else 0.00 end) As rest_999,] + ;
					[SUM(case when ?pdData <= NVL(a.datascad,TO_DATE('01011900', 'DDMMYYYY')) And a.incert = 0 then ] + ;
					[a.sold else 0.00 end) As termen,] + ;
					[SUM(decode(a.incert, 1, a.sold, 0.00)) As rest_incert ] + ;
					[FROM (Select id_part, ] + Iif(m.llGrupareAnalitic, [NVL(acont,'    ')], ['    ']) + [ as acont, NVL(datascad, dataact + 30) as datascad,] + ;
					[(precdeb + debit) - (preccred + credit) As sold,] + ;
					[(case when cont = '4118' then 1 else 0 end) As incert ] + ;
					[FROM ireg_parteneri ] + ;
					[WHERE NVL(dataact,TO_DATE('01011900','DDMMYYYY')) <= ?pdData ] + ;
					[And (precdeb + debit) - (preccred + credit) <> 0 ] + ;
					[and luna = ?gnLuna ] + ;
					[and an = ?gnAn ] + ;
					m.lcConditieAcont + ;
					gcCondSucursala + ;
					[and cont in ('4111', '4118')) a ] + ;
					[left join nom_parteneri b on a.id_part = b.id_part ] + ;
					[GROUP By a.id_part, b.denumire, a.acont ]  + ;
					IIF(m.llCuSold, [having SUM(a.sold) <> 0 ], []) + ;
					[order by b.denumire, a.acont]
				gcRaport = [rap_vechime_clienti]
		
			Case Thisform.ctip = [F]
				gcExplicatie = [FURNIZORI]
		
				text to m.lcSql textmerge noshow
				Select a.id_part,b.denumire, a.acont, Sum(a.sold) As sold,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime1 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime2 and ?gnVechime1<>0 and ?gnVechime2<>0 
					then a.sold else 0.00 end) As rest_1,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime3 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime4 and ?gnVechime3<>0 and ?gnVechime4<>0 
					then a.sold else 0.00 end) As rest_2,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime5 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime6 and ?gnVechime5<>0 and ?gnVechime6<>0 
					then a.sold else 0.00 end) As rest_3,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime7 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime8 and ?gnVechime7<>0 and ?gnVechime8<>0 
					then a.sold else 0.00 end) As rest_4,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime9 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime10 and ?gnVechime9<>0 and ?gnVechime10<>0 
					then a.sold else 0.00 end) As rest_5,
					SUM(case when ?pdData >= NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime11 and ?gnVechime11<>0 and ?gnVechime12<>0 then 
					a.sold else 0.00 end) As rest_999,
					SUM(case when ?pdData <= NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) then 
					a.sold else 0.00 end) As termen 
					FROM (Select id_part, <<Iif(llGrupareAnalitic, [NVL(acont,'    ')], ['    '])>> as acont, <<iif(this.lEmitere, [NVL(dataact, TO_DATE('] + m.lcEmptyData + [', 'YYYYMMDD'))], [nvl(datascad, dataact + 30)])>> as datascem,
					(preccred + credit) - (precdeb + debit) As sold 
					FROM ireg_parteneri 
					WHERE NVL(dataact,TO_DATE('<<m.lcEmptyData>>','YYYYMMDD')) <= ?pdData 
					And (preccred + credit) - (precdeb + debit) <> 0 
					and luna = ?gnLuna 
					and an = ?gnAn 
					<<lcConditieAcont>> 
					<<gcCondSucursala>>
					and cont = '401') a 
					left join nom_parteneri b on a.id_part = b.id_part 
					GROUP By a.id_part, b.denumire, a.acont 
					<<IIF(llCuSold, [having SUM(a.sold) <> 0 ], [])>>
					order by b.denumire, a.acont
				endtext 
		
				gcRaport = iif(this.lEmitere, [rap_vechime_emitere], [rap_vechime_furnizori])
		
			Case Thisform.ctip = [A]
		
				gcExplicatie = iif(m.pcCont = [4111], [CLIENTI], [ALTII])
				text to m.lcSql textmerge noshow
				Select a.id_part,b.denumire, a.acont, Sum(a.sold) As sold,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime1 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime2 and ?gnVechime1<>0 and ?gnVechime2<>0 
					then a.sold else 0.00 end) As rest_1,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime3 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime4 and ?gnVechime3<>0 and ?gnVechime4<>0 
					then a.sold else 0.00 end) As rest_2,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime5 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime6 and ?gnVechime5<>0 and ?gnVechime6<>0 
					then a.sold else 0.00 end) As rest_3,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime7 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime8 and ?gnVechime7<>0 and ?gnVechime8<>0 
					then a.sold else 0.00 end) As rest_4,
					SUM(case when ?pdData Between NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime9 and NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime10 and ?gnVechime9<>0 and ?gnVechime10<>0 
					then a.sold else 0.00 end) As rest_5,
					SUM(case when ?pdData >= NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) + ?gnVechime11 and ?gnVechime11<>0 and ?gnVechime12<>0 then 
					a.sold else 0.00 end) As rest_999,
					SUM(case when ?pdData <= NVL(a.datascem,TO_DATE('<<m.lcEmptyData>>', 'YYYYMMDD')) then 
					a.sold else 0.00 end) As termen 
					FROM (Select id_part, <<Iif(llGrupareAnalitic, [NVL(acont,'    ')], ['    '])>> as acont, <<iif(this.lEmitere, [NVL(dataact, TO_DATE('] + m.lcEmptyData + [', 'YYYYMMDD'))], [nvl(datascad, dataact + 30)])>> as datascem,
					<<iif(!m.pnEActiv, [(preccred + credit) - (precdeb + debit) As sold ], [(precdeb + debit) - (preccred + credit) As sold ])>>
					FROM ireg_parteneri 
					WHERE NVL(dataact,TO_DATE('<<m.lcEmptyData>>','YYYYMMDD')) <= ?pdData and
					<<iif(!m.pnEActiv, [ (preccred + credit) - (precdeb + debit) <> 0 ], [ (precdeb + debit) - (preccred + credit) <> 0 ])>>
					and luna = ?gnLuna and an = ?gnAn 
					<<m.lcConditieAcont>>
					<<m.gcCondSucursala>>
					and cont = ?m.pcCont) a 
					left join nom_parteneri b on a.id_part = b.id_part 
					GROUP By a.id_part, b.denumire, a.acont 
					<<IIF(m.llCuSold, [having SUM(a.sold) <> 0 ], [])>>
					order by b.denumire, a.acont
				endtext 
		
				gcRaport = iif(this.lEmitere, [rap_vechime_emitere], [rap_vechime_furnizori])
		ENDCASE
		
		lnSucces = goExecutor.oExecute(m.lcsql, [crsdaterap])
		If m.lnSucces < 0
			amessagebox(goExecutor.cEroare, 16, "Eroare")
		Endif
		*!*	adaugare v 2.0.77 ^
		
	ENDPROC

	PROCEDURE do_excel
		*!*	adaugare v 2.0.77
		Thisform.do_crsintervale()
		If Thisform.ctip=[C]
			lcselect=[SELECT id_part, denumire, sold, rest_1 as i_]+Alltrim(Str(gnVechime1))+;
				[_]+Alltrim(Str(gnVechime2))+[, rest_2 as i_]+Alltrim(Str(gnVechime3))+;
				[_]+Alltrim(Str(gnVechime4))+[,rest_3 as i_]+Alltrim(Str(gnVechime5))+[_]+Alltrim(Str(gnVechime6))+;
				[,rest_4 as i_]+Alltrim(Str(gnVechime7))+[_]+Alltrim(Str(gnVechime8))+[,rest_5 as i_]+;
				ALLTRIM(Str(gnVechime9))+[_]+Alltrim(Str(gnVechime10))+[,rest_999 as i_]+Alltrim(Str(gnVechime11))+;
				[_]+Alltrim(Str(gnVechime12))+[,rest_incert,termen FROM crsdaterap into cursor crsdatexls]
		Else
			lcselect=[SELECT id_part, denumire, sold, rest_1 as i_]+Alltrim(Str(gnVechime1))+;
				[_]+Alltrim(Str(gnVechime2))+[, rest_2 as i_]+Alltrim(Str(gnVechime3))+;
				[_]+Alltrim(Str(gnVechime4))+[,rest_3 as i_]+Alltrim(Str(gnVechime5))+[_]+Alltrim(Str(gnVechime6))+;
				[,rest_4 as i_]+Alltrim(Str(gnVechime7))+[_]+Alltrim(Str(gnVechime8))+[,rest_5 as i_]+;
				ALLTRIM(Str(gnVechime9))+[_]+Alltrim(Str(gnVechime10))+[,rest_999 as i_]+Alltrim(Str(gnVechime11))+;
				[_]+Alltrim(Str(gnVechime12))+[,termen FROM crsdaterap into cursor crsdatexls]
		Endif
		&lcselect
		goExport.export2xls([crsdatexls])
		If Used('crsdaterap')
			Use In crsdaterap
		Endif
		If Used('crsdatexls')
			Use In crsdatexls
		Endif
		*!*	adaugare v 2.0.77 ^
		
	ENDPROC

	PROCEDURE do_listare
		*!*	adaugare v 2.0.77
		Local llMultiPreview
		llMultiPreview = .T.
		lcAcont = Alltrim(This.txt_analitic.Value)
		Private pctitlu
		Public gcExplicatie,gcRaport
		Thisform.do_crsintervale()
		pctitlu = [SITUATIE ] + gcExplicatie + ' ' + '(Cont ' + Thisform.ccont + Iif(!Empty(m.lcAcont), '.' + m.lcAcont, '') + ')' + [ PE VECHIMI ] + iif(this.lEmitere, [EMITERE], [SCADENTA]) + [ LA DATA ] + Alltrim(Dtoc(pdData))
		Thisform.AlwaysOnTop= .F.
		goExport.export2frx([crsdaterap],gcRaport, , , , , , llMultiPreview, , )
		Thisform.AlwaysOnTop= .T.
		Release pctitlu,gcExplicatie,gcRaport
		*!*	adaugare v 2.0.77 ^
		
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		DoDefault()
		*!*	adaugare v 2.0.77
		Local lcSql
		lcSql = []
		Select crsOptiuni
		Scan
			lcNume = Alltrim(varname)
			lnValoare = Val(Alltrim(varvalue))
			If gn&lcNume. <> lnValoare
				lcSql=lcSql + [ update ]+gcS+[.optiuni set varvalue=] +Alltrim(Str(gn&lcNume.))+[ where varname like ']+lcNume+[';]
			Endif
		Endscan
		
		If lcSql#[]
			lnRaspuns=aMESSAGEBOX("Doriti sa salvati intervalele alese?",36,"Atentie")
			If lnRaspuns=6
				lcSql = [begin ] + lcSql + [ end;]
				lnSucces=goExecutor.oExecute(lcSql)
				If lnSucces < 0
					aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
					Return
				Endif
			Endif
		Endif
		*!*	adaugare v 2.0.77 ^
		
	ENDPROC

	PROCEDURE Init
		Lparameters tctip, tcCont, tlEmitere
		*** tcTip: C (clienti 4111,4118); F (furnizori 401); A (activ se alege contul)
		*** tlEmitere: .T. vechime fata de data emiterii sau .F. fata de data scadenta
		
		LOCAL lcTip,lcCont
		lcTip = IIF(!EMPTY(tcTip), tcTip, "")
		lcCont = tcCont
		DO case
			CASE lcTip = 'C'
				lcCont = '4111,4118'
			CASE lcTip = 'F'
				lcCont = '401'
		endcase
		
							
		Thisform.ctip = lcTip
		thisform.cCont = lcCont
		Thisform.lEmitere = m.tlEmitere 
		DODEFAULT()
	ENDPROC

	PROCEDURE lansanalitic
		Local lcColoane, lcCont, lcFiltru, lcFiltruOriginal, lcSchema, lcSql, lcTitlu, lcTitluColoane
		Local lcorder, lnPos, locauta
		lcSql = [select explicatie,cont, acont from VPLCONT_USED_ANALITIC]
		lcFiltru = [1=2]
		lcSchema = []
		lcorder = [acont]
		lcColoane = [acont,explicatie]
		lcTitlu = [Alegeti Contul Analitic]
		lcTitluColoane = [Cont Analitic,Explicatie cont]
		lcCont = Thisform.cCont && 4111,4118 / 401 / xxxx
		lnPos = AT(',', lcCont)
		IF lnPos > 0
			lcCont = LEFT(lcCont, lnPos-1)
		ENDIF 	
		
		lcFiltruOriginal = [an = ?gnAn and cont = '] + m.lcCont + [']
		locauta = cauta_alfa(lcSql, lcFiltru, lcSchema, lcOrder, lcColoane, lcTitlu, lcTitluColoane,'',.T., lcFiltruOriginal)
		This.txt_analitic.Value = IIF(LEFT(UPPER(locauta.acont),4)='<TOA', '', locauta.acont)
		this.txt_analitic.Refresh() 
	ENDPROC

	PROCEDURE Txt_analitic.GotFocus
		thisform.lansanalitic()
	ENDPROC

	PROCEDURE _spinner1.Valid
		gnVechime1=thisform._spinner1.Value
		
	ENDPROC

	PROCEDURE _spinner10.Valid
		gnVechime10=thisform._spinner10.Value
		IF thisform._spinner9.Value<>0
		IF thisform._spinner10.Value<thisform._spinner9.Value
		amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
		RETURN
		ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE _spinner11.GotFocus
		IF thisform._spinner10.Value<>0
		thisform._spinner11.Value=thisform._spinner10.Value+1
		ENDIF 
	ENDPROC

	PROCEDURE _spinner11.Valid
		gnVechime11=thisform._spinner11.Value
		
	ENDPROC

	PROCEDURE _spinner12.Valid
		gnVechime12=Thisform._spinner12.Value
		If Thisform._spinner11.Value<>0
			If Thisform._spinner12.Value<Thisform._spinner11.Value
				amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
				Return
			Endif
		Endif
		
	ENDPROC

	PROCEDURE _spinner2.Valid
		gnVechime2=thisform._spinner2.Value
		IF thisform._spinner1.Value<>0
		IF thisform._spinner2.Value<thisform._spinner1.Value
		amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
		RETURN
		ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE _spinner3.GotFocus
		IF thisform._spinner2.Value<>0
		thisform._spinner3.Value=thisform._spinner2.Value+1
		ENDIF 
	ENDPROC

	PROCEDURE _spinner3.Valid
		gnVechime3=thisform._spinner3.Value
		
	ENDPROC

	PROCEDURE _spinner4.Valid
		gnVechime4=thisform._spinner4.Value
		IF thisform._spinner3.Value<>0
		IF thisform._spinner4.Value<thisform._spinner3.Value
		amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
		RETURN
		ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE _spinner5.GotFocus
		If Thisform._spinner4.Value<>0
			Thisform._spinner5.Value=Thisform._spinner4.Value+1
		Endif
		
	ENDPROC

	PROCEDURE _spinner5.Valid
		gnVechime5=thisform._spinner5.Value
		
	ENDPROC

	PROCEDURE _spinner6.Valid
		gnVechime6=Thisform._spinner6.Value
		If Thisform._spinner5.Value<>0
			If Thisform._spinner6.Value<Thisform._spinner5.Value
				amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
				Return
			Endif
		Endif
		
	ENDPROC

	PROCEDURE _spinner7.GotFocus
		IF thisform._spinner6.Value<>0
		thisform._spinner7.Value=thisform._spinner6.Value+1
		ENDIF 
	ENDPROC

	PROCEDURE _spinner7.Valid
		gnVechime7=thisform._spinner7.Value
		
	ENDPROC

	PROCEDURE _spinner8.Valid
		gnVechime8=thisform._spinner8.Value
		IF thisform._spinner7.Value<>0
		IF thisform._spinner8.Value<thisform._spinner7.Value
		amessagebox("Capatul din dreapta trebuie sa fie mai mare decat capatul din stanga",48,"Atentie")
		RETURN
		ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE _spinner9.GotFocus
		IF thisform._spinner8.Value<>0
		thisform._spinner9.Value=thisform._spinner8.Value+1
		ENDIF 
	ENDPROC

	PROCEDURE _spinner9.Valid
		gnVechime9=thisform._spinner9.Value
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_cartea_mare AS frm_termin OF "..\comun\clase\_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="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cAles.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cAles.Check1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cCont.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cCont.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cExplicatie.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdConturi.cExplicatie.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboAlese" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboCorespondente" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdSelecteaza" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: ales_dblclick
		*m: update_ireg
		*p: nid_part
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cgridsortlist = grdConturi
		DoCreate = .T.
		Height = 504
		Name = "frm_cartea_mare"
		nid_part = -1
		Width = 415
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 670
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 350
		_shape2.Name = "_shape2"
		_shape2.Top = -1
		_shape2.Width = 67
		Lb_titlu_alb_b121.Caption = "CARTEA MARE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.FontSize = 11
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 385
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 6
		BUT_TERMIN1.Top = 0
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Anchor = 9, ;
		Left = 355, ;
		Name = "But_listare1", ;
		TabIndex = 5, ;
		Top = 0
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cboAlese' AS combobox WITH ;
		Height = 24, ;
		Left = 204, ;
		Name = "cboAlese", ;
		RowSource = "Afiseaza toate,Afiseaza selectate", ;
		RowSourceType = 1, ;
		Style = 2, ;
		TabIndex = 3, ;
		Top = 80, ;
		Value = Afiseaza toate, ;
		Width = 192
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cboCorespondente' AS combobox WITH ;
		Height = 24, ;
		Left = 204, ;
		Name = "cboCorespondente", ;
		RowSource = "Credit,Debit", ;
		RowSourceType = 1, ;
		Style = 2, ;
		Top = 43, ;
		Value = Debit, ;
		Width = 192
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'clb_cont' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 14, ;
		Name = "clb_cont", ;
		TabIndex = 1, ;
		Top = 41, ;
		Width = 142, ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 52, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 83, ;
		Lb_simplu1.Caption = "Cont", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'cmdSelecteaza' AS cmd_select_adv WITH ;
		ccoloana = ales, ;
		cgrid = thisform.grdConturi, ;
		Left = 12, ;
		Name = "cmdSelecteaza", ;
		Top = 80
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grdConturi' AS _grdbase WITH ;
		ColumnCount = 3, ;
		DeleteMark = .F., ;
		Height = 381, ;
		Left = 10, ;
		Name = "grdConturi", ;
		Panel = 1, ;
		RecordSource = "cConturiTemp", ;
		TabIndex = 4, ;
		Top = 115, ;
		Width = 398, ;
		Column1.ControlSource = "ales", ;
		Column1.CurrentControl = "Check1", ;
		Column1.Name = "cAles", ;
		Column1.Sparse = .F., ;
		Column1.Width = 35, ;
		Column2.ControlSource = "cont", ;
		Column2.Name = "cCont", ;
		Column2.Width = 65, ;
		Column3.ControlSource = "explicatie", ;
		Column3.Name = "cExplicatie", ;
		Column3.Width = 241
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grdConturi.cAles.Check1' AS checkbox WITH ;
		Alignment = 2, ;
		Caption = "", ;
		Centered = .T., ;
		Height = 17, ;
		Left = 37, ;
		Name = "Check1", ;
		Top = 47, ;
		Width = 60
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'grdConturi.cAles.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Ales", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConturi.cCont.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConturi.cCont.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdConturi.cExplicatie.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Explicatie", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdConturi.cExplicatie.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE ales_dblclick
	ENDPROC

	PROCEDURE Destroy
		USE IN (SELECT('CCONTURITEMP'))
	ENDPROC

	PROCEDURE do_cauta
		lcFiltru = ""
		lcAfiseaza = this.cboAlese.Value
		lcValoare = ALLTRIM(THIS.clb_cont.text_simplu1.VALUE)
		SELECT cConturiTemp
		IF !EMPTY(lcValoare)
			IF lcAfiseaza = "Afiseaza selectate"
				lcFiltru = "ales = 1 and "
			ELSE 
				lcFiltru = "ales = 1 or "		
			ENDIF 	
			lcFiltru = lcFiltru + "LEFT(CONT," + STR(LEN(lcValoare)) + ") = '" + lcValoare + "'"		
		ELSE 
			IF lcAfiseaza = "Afiseaza selectate"
				lcFiltru = "ales = 1"
			ELSE 	
				lcFiltru = "1 = 1"		
			ENDIF 	
		ENDIF 
		SET FILTER TO &lcFiltru
		LOCATE FOR ales = 1
		IF !FOUND()
			GO TOP 
		ENDIF 	
				
		THIS.grdConturi.SETFOCUS()
		
		
	ENDPROC

	PROCEDURE do_listare
		This.but_listare1.SetFocus()
		Local lcListaConturi, lcFiltru, lnRecno, lcCorespondente
		lcListaConturi = ""
		Select cConturiTemp
		lnRecno = Recno()
		lcFiltru = Filter()
		Set Filter To ales = 1
		Scan
			lcListaConturi = lcListaConturi + "," + Alltrim(Cont)
		Endscan
		lcCorespondente = Iif(This.cboCorespondente.Value = 'Credit', 'C', 'D')
		Set Filter To &lcFiltru
		Goto lnRecno
		This.AlwaysOnTop = .F.
		If !Empty(lcListaConturi)
			lcListaConturi = Substr(lcListaConturi,2)
		
			Do cartea_mare With lcListaConturi, lcCorespondente In orapoarte.prg
		Endif
		This.AlwaysOnTop = .T.
		This.clb_cont.SetFocus()
	ENDPROC

	PROCEDURE Load
		lcSql = [select distinct 0 as ales, cont, denumire as  explicatie ] + ;
			[from vbal where an = ?gnAn and luna = ?gnLuna ] + gcCondSucursala + ;
			[order by cont]
		
		lnSucces = goExecutor.oExecute(lcSql, "cConturiTemp")
		IF lnSucces < 0
			amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
			RETURN 
		ENDIF 	
		
	ENDPROC

	PROCEDURE update_ireg
	ENDPROC

	PROCEDURE cboAlese.Valid
		thisform.do_cauta()
		
			
	ENDPROC

	PROCEDURE clb_cont.Text_simplu1.LostFocus
		thisform.do_cauta()
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_caut_anluna AS _frmbase OF "..\comun\clase\_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_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Caut_anluna" UniqueID="" Timestamp="" />

	*<PropValue>
		BorderStyle = 2
		DoCreate = .T.
		FontName = "Arial Narrow"
		Height = 130
		Name = "frm_caut_anluna"
		Width = 250
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape2.Height = 29
		_shape2.Left = 190
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 61
		Lb_titlu_alb_b121.Caption = "Luna initiala"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Left = 220
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 191, ;
		Name = "But_renunt1", ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Caut_anluna' AS caut_anluna WITH ;
		Left = 50, ;
		Name = "Caut_anluna", ;
		Top = 90, ;
		cboan.Name = "cboan", ;
		cboluna.Name = "cboluna"
		*< END OBJECT: ClassLib="..\comun\clase\caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Label5' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Selectati luna de inceput pentru calculul recapitulatiilor:", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 41, ;
		Left = 12, ;
		Name = "Label5", ;
		TabIndex = 8, ;
		Top = 45, ;
		Width = 216, ;
		WordWrap = .T., ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE inainte_de_do_termin
		pnan = thisform.caut_anluna.nan
		pnluna = thisform.caut_anluna.nluna
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_datorii_buget AS frm_termin OF "..\comun\clase\_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="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdbase1.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu1" UniqueID="" Timestamp="" />

	*<PropValue>
		BorderStyle = 2
		DoCreate = .T.
		Height = 483
		Name = "frm_datorii_buget"
		Width = 495
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 540
		_SHAPE2.Height = 29
		_SHAPE2.Left = 432
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Width = 63
		LB_TITLU_ALB_B121.Caption = "Datorii catre buget"
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		BUT_TERMIN1.Left = 463
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_grdbase1' AS _grdbase WITH ;
		ColumnCount = 4, ;
		DeleteMark = .F., ;
		FontName = "Arial", ;
		Height = 381, ;
		Left = 12, ;
		Name = "_grdbase1", ;
		Panel = 1, ;
		Top = 48, ;
		Width = 468, ;
		Column1.ControlSource = "cont", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "Column1", ;
		Column1.Width = 56, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "denumire", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "Column2", ;
		Column2.Width = 215, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "suma", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.InputMask = (get_mask(12,gnPA)), ;
		Column3.Name = "Column3", ;
		Column3.Width = 99, ;
		Column4.ColumnOrder = 2, ;
		Column4.ControlSource = "acont", ;
		Column4.FontName = "Arial", ;
		Column4.Name = "Column4", ;
		Column4.Width = 64
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdbase1.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdbase1.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdbase1.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdbase1.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdbase1.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Suma", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdbase1.Column3.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdbase1.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Acont", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdbase1.Column4.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Left = 432, ;
		Name = "But_listare1", ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_tx_simplu1' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 304, ;
		Name = "Clb_tx_simplu1", ;
		Top = 441, ;
		Width = 176, ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.InputMask = (get_mask(16,gnPA)), ;
		Text_simplu1.Left = 43, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 128, ;
		Lb_simplu1.Caption = "Total", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />
	
	PROCEDURE do_executa
		lcSel = thisform._grdbase1.RecordSource
		SELECT (lcSel)
		SUM suma TO lnTotal
		this.clb_tx_simplu1.text_simplu1.Value = lnTotal
		
	ENDPROC

	PROCEDURE do_listare
		Select * From crs_datorii Where suma <> 0 Into Cursor cList
		
		*!*	If Reccount('cList')>0
		*!*		This.AlwaysOnTop = .F.
		*!*		pcDataOra = get_ora(2)
		*!*		Select cList
		*!*		Report Form rap_algdator To Printer Prompt Preview
		*!*		This.AlwaysOnTop = .T.
		*!*	Else
		*!*		amessagebox("Nu exista inregistrari pentru listare!",48,"Atentie")
		*!*	Endif
		Thisform.AlwaysOnTop = .F.
		goExport.export2frx([cList],[rap_algdator])
		Thisform.AlwaysOnTop = .T.
		If Used('cList')
			Use In cList
		Endif
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		thisform.do_executa 
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_facturi_grupat AS frm_termin_renunt 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="Clb_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu3" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_lanscont
		*m: do_lanslucrare
		*p: lccont
		*p: lctitlu
		*p: llactiv
		*p: lnidlucrare
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 2
		DoCreate = .T.
		Height = 151
		lccont = 
		lctitlu = 
		llactiv = 
		lnidlucrare = 0
		Name = "frm_facturi_grupat"
		Width = 374
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 309
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 65
		Lb_titlu_alb_b121.Caption = "Situatie facuri"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 4
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		Gridsort1.Left = 5
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 34
		But_renunt1.Name = "But_renunt1"
		But_renunt1.TabIndex = 6
	*</PropValue>

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		caction = do_lansLucrare, ;
		Left = 311, ;
		Name = "But_cautare1", ;
		TabIndex = 3, ;
		Top = 110
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_cautare_cont' AS but_cautare WITH ;
		caction = do_lansCont, ;
		Left = 311, ;
		Name = "But_cautare_cont", ;
		TabIndex = 2, ;
		Top = 80
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_tx_simplu1' AS clb_tx_simplu WITH ;
		Left = 18, ;
		Name = "Clb_tx_simplu1", ;
		TabIndex = 7, ;
		TabStop = .F., ;
		Top = 81, ;
		ZOrderSet = 6, ;
		Text_simplu1.BackColor = 255,255,255, ;
		Text_simplu1.BackStyle = 0, ;
		Text_simplu1.BorderColor = 0,0,0, ;
		Text_simplu1.DisabledBackColor = 255,255,255, ;
		Text_simplu1.DisabledForeColor = 255,255,255, ;
		Text_simplu1.FontItalic = .T., ;
		Text_simplu1.ForeColor = 0,0,0, ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 65, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 220, ;
		Lb_simplu1.Caption = "Cont", ;
		Lb_simplu1.FontSize = 10, ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu2' AS clb_tx_simplu WITH ;
		Left = 18, ;
		Name = "Clb_tx_simplu2", ;
		TabIndex = 8, ;
		TabStop = .F., ;
		Top = 109, ;
		ZOrderSet = 7, ;
		Text_simplu1.BackColor = 255,255,255, ;
		Text_simplu1.BackStyle = 0, ;
		Text_simplu1.DisabledBackColor = 255,255,255, ;
		Text_simplu1.DisabledForeColor = 255,255,255, ;
		Text_simplu1.FontItalic = .T., ;
		Text_simplu1.ForeColor = 0,0,0, ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 65, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 220, ;
		Lb_simplu1.Caption = "Lucrare", ;
		Lb_simplu1.FontSize = 10, ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu3' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 18, ;
		Name = "Clb_tx_simplu3", ;
		TabIndex = 1, ;
		Top = 44, ;
		Width = 326, ;
		Text_simplu1.ControlSource = "thisform.lcTitlu", ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 73, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 249, ;
		Lb_simplu1.Caption = "Titlu raport", ;
		Lb_simplu1.FontSize = 10, ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />
	
	PROCEDURE do_lanscont
		private lcCont,lnEActiv 
		STORE "" TO lcCont
		STORE .F. TO lnEActiv
		DO Alege_Cont WITH lcCont,lnEActiv 
		
		IF !EMPTY(lcCont)
			this.clb_tx_simplu1.text_simplu1.Value = lcCont
			this.lccont = lcCont
			this.llactiv = lnEActiv
		ENDIF 
		
	ENDPROC

	PROCEDURE do_lanslucrare
		PRIVATE pcval,pnbuton,pcselect,pcfiltru,oRetObj
		STORE "" TO oRetObj
		pcselect = [select id_lucrare, nrord from vlucrari_validat]
		pcfiltru = [1=2]
		pcschema = []
		pcorder = [nrord]
		pccoloane = [nrord]
		pcTitlu = [Alegeti lucrarea/contractul]
		pcFiltruOriginal = [validat = 0 and inactiv = 0]
		oRetObj = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitlu,[],.T.,pcFiltruOriginal) && 11.07.2007
		lnIdLucrare = IIF(EMPTY(oRetObj.id_lucrare), 0, oRetObj.id_lucrare)
		this.clb_tx_simplu2.text_simplu1.Value = oRetObj.nrord
		this.lnidLucrare = lnIdLucrare
		 
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_facturi_scadente 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="Shape4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txt_dataref" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_text2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="optluni" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_lbbase2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtPenalitati" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_lbbase1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_text3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txt_datamax" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_lbbase5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_lbbase4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkPenalitatiTot" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkPenalitatiNegativ" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: calcul_datamax
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		DoCreate = .T.
		Height = 322
		Name = "frm_facturi_scadente"
		Width = 290
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 380
		_shape1.ZOrderSet = 3
		_shape2.Height = 29
		_shape2.Left = 230
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 61
		_shape2.ZOrderSet = 4
		Lb_titlu_alb_b121.Caption = "Facturi scadente"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 11
		Lb_titlu_alb_b121.ZOrderSet = 5
		BUT_TERMIN1.Left = 260
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 8
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_lbbase1' AS _lbbase WITH ;
		Alignment = 0, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 0, ;
		Caption = "Procent penalitati (%):", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 17, ;
		Name = "_lbbase1", ;
		TabIndex = 10, ;
		Top = 248, ;
		Width = 183, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT '_lbbase2' AS _lbbase WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		BorderStyle = 0, ;
		Caption = "Penalitati", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 19, ;
		Name = "_lbbase2", ;
		TabIndex = 16, ;
		Top = 226, ;
		Width = 50, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT '_lbbase4' AS _lbbase WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		BorderStyle = 0, ;
		Caption = "Fata de data", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 19, ;
		Name = "_lbbase4", ;
		TabIndex = 15, ;
		Top = 55, ;
		Width = 68, ;
		ZOrderSet = 14
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT '_lbbase5' AS _lbbase WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		Caption = "Facturi cu data scadenta mai veche de:", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 17, ;
		Name = "_lbbase5", ;
		TabIndex = 3, ;
		Top = 188, ;
		Width = 183, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 231, ;
		Name = "But_renunt1", ;
		TabIndex = 9, ;
		Top = 1, ;
		ZOrderSet = 7
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'chkPenalitatiNegativ' AS _checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "Se calculeaza penalitati la sold negativ", ;
		FontCharSet = 1, ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 17, ;
		Name = "chkPenalitatiNegativ", ;
		TabIndex = 7, ;
		Top = 288, ;
		Width = 196, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'chkPenalitatiTot' AS _checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "Se afiseaza si facturile in termen fara penalitati", ;
		FontCharSet = 1, ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 17, ;
		Name = "chkPenalitatiTot", ;
		TabIndex = 6, ;
		Top = 269, ;
		Width = 230, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'lbl_text1' AS _lbbase WITH ;
		Caption = "Afiseaza facturi care au depasit termenul de scadenta", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Left = 12, ;
		Name = "lbl_text1", ;
		TabIndex = 12, ;
		Top = 36, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'lbl_text2' AS _lbbase WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		BorderStyle = 0, ;
		Caption = "Cu mai mult de", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 19, ;
		Name = "lbl_text2", ;
		TabIndex = 13, ;
		Top = 112, ;
		Width = 80, ;
		ZOrderSet = 10
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'lbl_text3' AS _lbbase WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		BorderStyle = 0, ;
		Caption = "Afiseaza", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 19, ;
		Name = "lbl_text3", ;
		TabIndex = 14, ;
		Top = 166, ;
		Width = 50, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'optluni' AS optiongroup WITH ;
		BackStyle = 0, ;
		BorderColor = 0,0,0, ;
		BorderStyle = 0, ;
		ButtonCount = 4, ;
		Height = 25, ;
		Left = 33, ;
		Name = "optluni", ;
		SpecialEffect = 1, ;
		TabIndex = 2, ;
		Top = 130, ;
		Value = 1, ;
		Width = 240, ;
		ZOrderSet = 11, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "0 luni", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 1, ;
		Option1.Width = 43, ;
		Option2.AutoSize = .T., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "1 luna", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Height = 18, ;
		Option2.Left = 60, ;
		Option2.Name = "Option2", ;
		Option2.Top = 5, ;
		Option2.Width = 47, ;
		Option3.BackColor = 255,255,255, ;
		Option3.Caption = "2 luni", ;
		Option3.FontName = "Arial Narrow", ;
		Option3.FontSize = 10, ;
		Option3.Height = 17, ;
		Option3.Left = 119, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 50, ;
		Option4.BackColor = 255,255,255, ;
		Option4.Caption = "3 luni", ;
		Option4.FontName = "Arial Narrow", ;
		Option4.FontSize = 10, ;
		Option4.Height = 17, ;
		Option4.Left = 181, ;
		Option4.Name = "Option4", ;
		Option4.Top = 5, ;
		Option4.Width = 50
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		BackColor = 255,255,255, ;
		Height = 40, ;
		Left = 12, ;
		Name = "Shape1", ;
		Top = 64, ;
		Width = 157, ;
		ZOrderSet = 2
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackColor = 255,255,255, ;
		Height = 40, ;
		Left = 12, ;
		Name = "Shape2", ;
		Top = 120, ;
		Width = 266, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackColor = 255,255,255, ;
		BorderColor = 0,0,0, ;
		Height = 40, ;
		Left = 12, ;
		Name = "Shape3", ;
		Top = 176, ;
		Width = 267, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape4' AS shape WITH ;
		BackColor = 255,255,255, ;
		BorderColor = 0,0,0, ;
		Height = 83, ;
		Left = 12, ;
		Name = "Shape4", ;
		Top = 236, ;
		Width = 267, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'txt_datamax' AS _txbase WITH ;
		BackColor = 255,255,255, ;
		Enabled = .F., ;
		FontName = "Arial", ;
		Height = 23, ;
		Left = 202, ;
		Name = "txt_datamax", ;
		TabIndex = 4, ;
		Top = 185, ;
		Width = 72, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="_tx_base.vcx" BaseClass="textbox" />

	ADD OBJECT 'txt_dataref' AS _txbase WITH ;
		FontName = "Arial", ;
		Height = 23, ;
		Left = 90, ;
		Name = "txt_dataref", ;
		TabIndex = 1, ;
		Top = 74, ;
		Width = 72, ;
		ZOrderSet = 9
		*< END OBJECT: ClassLib="_tx_base.vcx" BaseClass="textbox" />

	ADD OBJECT 'txtPenalitati' AS _txbase WITH ;
		BackColor = 255,255,255, ;
		Enabled = .T., ;
		FontName = "Arial", ;
		Height = 23, ;
		Left = 202, ;
		Name = "txtPenalitati", ;
		TabIndex = 5, ;
		Top = 245, ;
		Width = 72, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="_tx_base.vcx" BaseClass="textbox" />
	
	PROCEDURE calcul_datamax
		LOCAL lnnrluni,lddataref
		
		lddataref = thisform.txt_dataref.value
		lnnrluni = thisform.optluni.value - 1
		
		thisform.txt_datamax.Value = GOMONTH(lddataref,-lnnrluni)
		thisform.txt_datamax.refresh
		
		
		
	ENDPROC

	PROCEDURE Init
		LPARAMETERS tlPenalitati
		
		* tlPenalitati = .T. daca se afiseaza sectiunea penalitati
		
		*** ascund sectiunea penalitati
		IF PCOUNT() = 0 OR tlPenalitati = .F.
			This.Height = 225
			this.txtPenalitati.Enabled = .F.
			this.chkPenalitatiTot.Enabled = .F.
			this.chkPenalitatiNegativ.Enabled = .F.  
		ENDIF 
	ENDPROC

	PROCEDURE optluni.Valid
		thisform.calcul_datamax
		pnnrluni = this.Value -1
		
	ENDPROC

	PROCEDURE txt_dataref.Valid
		IF this.Value > DATE()
			aMESSAGEBOX('Data incorecta! Data maxima este data curenta.',0+48,"Atentie")
			RETURN .F.
		ELSE
			thisform.calcul_datamax		
		ENDIF
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_istoric_clienti 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="grd_facturi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNr_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNr_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cData_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cData_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_val_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_val_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNume_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNume_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSerie_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSerie_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="LB_SIMPLU1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_incasate" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_nr_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_serie_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_data_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNr_incasare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNr_incasare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cData_incasare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cData_incasare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNume_val_inc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNume_val_inc.Text1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_arata_meniu
		*m: do_deschide_document
	*</DefinedPropArrayMethod>

	*<PropValue>
		cgridsortlist = grd_facturi
		DoCreate = .T.
		Height = 489
		Name = "frm_istoric_clienti"
		Width = 779
		WindowState = 2
		_SHAPE1.Anchor = 10
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 780
		_SHAPE2.Anchor = 9
		_SHAPE2.Height = 29
		_SHAPE2.Left = 719
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Width = 60
		LB_TITLU_ALB_B121.Caption = "Istoric facturi"
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 749
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 756
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 48
	*</PropValue>

	ADD OBJECT 'But_reset_criterii1' AS but_reset_criterii WITH ;
		Anchor = 9, ;
		Left = 720, ;
		Name = "But_reset_criterii1", ;
		Top = 1
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ck_data_factura' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = data_factura, ;
		Caption = "Data factura", ;
		Left = 17, ;
		Name = "Ck_data_factura", ;
		tip = D, ;
		Top = 66
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_nr_factura' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = nr_factura, ;
		Caption = "Nr.factura", ;
		Left = 17, ;
		Name = "Ck_nr_factura", ;
		Top = 50
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_serie_factura' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		camp_nume = serie_factura, ;
		Caption = "Serie factura", ;
		Left = 17, ;
		Name = "Ck_serie_factura", ;
		Top = 33
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grd_facturi' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 7, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		HeaderHeight = 38, ;
		Height = 374, ;
		Left = 11, ;
		Name = "grd_facturi", ;
		Panel = 1, ;
		RecordSource = "crsistoric", ;
		RowHeight = 19, ;
		Top = 96, ;
		Width = 420, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "nr_factura", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_factura", ;
		Column1.Width = 113, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "data_factura", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_factura", ;
		Column2.Width = 86, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "suma_factura", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.InputMask = (get_mask(14,gnPa)), ;
		Column3.Name = "cSuma_factura", ;
		Column3.Width = 84, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "suma_val_factura", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPVal)), ;
		Column4.Name = "cSuma_val_factura", ;
		Column4.Width = 97, ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "nume_val", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cNume_val", ;
		Column5.Width = 47, ;
		Column6.ColumnOrder = 1, ;
		Column6.ControlSource = "serie_factura", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cSerie_factura", ;
		Column6.Width = 77, ;
		Column7.ControlSource = "incasat", ;
		Column7.FontName = "Arial", ;
		Column7.FontSize = 10, ;
		Column7.InputMask = (get_mask(14,gnPa)), ;
		Column7.Name = "cIncasat", ;
		Column7.Width = 101
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_facturi.cData_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data factura", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cData_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cIncasat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cIncasat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cNr_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. factura", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cNr_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cNume_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cNume_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSerie_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Serie factura", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSerie_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSuma_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Suma in lei", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSuma_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSuma_val_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Suma in valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSuma_val_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari' AS _grdrow WITH ;
		Anchor = 8, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		HeaderHeight = 36, ;
		Height = 374, ;
		Left = 436, ;
		Name = "grd_incasari", ;
		Panel = 1, ;
		RecordSource = "crsincasari", ;
		RowHeight = 19, ;
		Top = 96, ;
		Width = 336, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "nr_incasare", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_incasare", ;
		Column1.Width = 74, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "TTOD(data_incasare)", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_incasare", ;
		Column2.Width = 84, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "incasat", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.InputMask = (get_mask(14,gnPa)), ;
		Column3.Name = "cIncasat", ;
		Column3.Width = 95, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "incasat_val", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPVal)), ;
		Column4.Name = "cIncasat_val", ;
		Column4.Width = 95, ;
		Column5.ColumnOrder = 5, ;
		Column5.ControlSource = "nume_val_inc", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cNume_val_inc", ;
		Column5.Width = 61
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_incasari.cData_incasare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data incasare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cData_incasare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cIncasat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cIncasat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cIncasat_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Incasat in valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cIncasat_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cNr_incasare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. incasare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cNr_incasare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cNume_val_inc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta incasare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cNume_val_inc.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'LB_SIMPLU1' AS lb_simplu WITH ;
		Caption = '      Pentru a vizualiza documentele salvate in baza de date, trebuie sa faceti click dreapta pe coloana "Nr.factura" ( doar inregistrarile colorate au atasamente ).', ;
		FontSize = 8, ;
		Height = 30, ;
		Left = 122, ;
		Name = "LB_SIMPLU1", ;
		Top = 65, ;
		Width = 641, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'opt_incasate' AS _optiongrup WITH ;
		ButtonCount = 5, ;
		Height = 27, ;
		Left = 123, ;
		Name = "opt_incasate", ;
		Top = 33, ;
		Width = 613, ;
		Option1.Caption = "Toate", ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.AutoSize = .T., ;
		Option2.Caption = "Neincasate", ;
		Option2.Left = 75, ;
		Option2.Name = "Option2", ;
		Option2.Top = 5, ;
		Option3.AutoSize = .T., ;
		Option3.BackColor = 255,255,255, ;
		Option3.Caption = "Incasate partial", ;
		Option3.Height = 17, ;
		Option3.Left = 171, ;
		Option3.Name = "Option3", ;
		Option3.Top = 5, ;
		Option3.Width = 102, ;
		Option4.AutoSize = .T., ;
		Option4.BackColor = 255,255,255, ;
		Option4.Caption = "Neincasate sau incasate partial", ;
		Option4.Height = 17, ;
		Option4.Left = 291, ;
		Option4.Name = "Option4", ;
		Option4.Top = 5, ;
		Option4.Width = 192, ;
		Option5.AutoSize = .T., ;
		Option5.BackColor = 255,255,255, ;
		Option5.Caption = "Incasate complet", ;
		Option5.Height = 17, ;
		Option5.Left = 496, ;
		Option5.Name = "Option5", ;
		Option5.Top = 5, ;
		Option5.Width = 112
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />
	
	PROCEDURE actualizeaza_grid2
		Lparameters tnIdFact
		If !Empty(tnIdFact)
			lcFiltru = [id_fact = ] + Alltrim(Str(tnIdFact))
		Else
			lcFiltru = [1=2]
		Endif
		Select crsincasari
		Set Filter To &lcFiltru
		Go Top
		Thisform.grd_incasari.Refresh()
		
	ENDPROC

	PROCEDURE do_arata_meniu
		Local lnCod,lnNrAct,lcSerie
		Select crsistoric
		lnCod =  cod
		lnNrAct = nr_factura
		lcSerie = Alltrim(Nvl(serie_factura,[]))
		If Used('crsmeniu')
			Use In crsmeniu
		Endif
		lcSql = [select a.id_at_vanz,a.tip,a.tip_doc from ] + gcS + [.vatasamente_vanzari a where a.cod = ] + Alltrim(Str(lnCod)) + [ order by a.tip]
		lnSucces = goExecutor.oExecute(lcSql,[crsmeniu])
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,16,"Eroare")
		Else
			Do Case
			Case Reccount('crsmeniu') = 1
				Thisform.do_deschide_document(crsmeniu.id_at_vanz,crsmeniu.tip_doc,lnNrAct)
			Case Reccount('crsmeniu')>0
				lcMeniu = []
				Select crsmeniu
				Scan
					lcMeniu = lcMeniu + [;] + Alltrim(tip_doc)
				Endscan
				x = xmenu(Substr(lcMeniu,2))
				Select crsmeniu
				Go x
				Thisform.do_deschide_document(crsmeniu.id_at_vanz,crsmeniu.tip_doc,lnNrAct)
			Otherwise
				amessagebox("Nu exista documente salvate in baza de date pentru factura "+lcSerie+" "+Alltrim(Str(lnNrAct,14,0)) + " !",48,"Atentie")
			Endcase
			Use In crsmeniu
		Endif
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		lnOptiune = Thisform.opt_incasate.Value
		lcFiltru = [2=2]
		
		If Thisform.ck_serie_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_serie_factura.filtru_vfp
		Endif
		
		If Thisform.ck_nr_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_nr_factura.filtru_vfp
		Endif
		
		If Thisform.ck_data_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_data_factura.filtru_vfp
		Endif
		
		Do Case
		Case lnOptiune = 1
			lcFiltru = lcFiltru + [ AND 2=2]
		Case lnOptiune = 2
			lcFiltru = lcFiltru + [ AND Nvl(sold,0) = suma_factura]
		Case lnOptiune = 3
			lcFiltru = lcFiltru + [ AND Nvl(sold,0) <> 0 and suma_factura <> Nvl(sold,0)]
		Case lnOptiune = 4
			lcFiltru = lcFiltru + [ AND Nvl(sold,0) <> 0]
		Case lnOptiune = 5
			lcFiltru = lcFiltru + [ AND Nvl(sold,0) = 0]
		Endcase
		Select crsistoric
		Set Filter To &lcFiltru
		Go Top
		Thisform.actualizeaza_grid2(id_fact)
		Thisform.grd_facturi.Refresh()
	ENDPROC

	PROCEDURE do_deschide_document
		Lparameters tnIdAtVanz,tcTip,tnNrAct
		If !Empty(tnIdAtVanz)
			Private poDocument
			Store "" To poDocument
			If Used('crsat')
				Use In crsat
			Endif
		
			Thisform.AlwaysOnTop = .F.
			Local loTherm
			loTherm = Newobject("_thermometer","_therm","","Citire document din baza de date...")
			loTherm.Show()
		
			lcSelect = [select document from ] + gcS + [.atasamente_vanzari where ]
			lcFiltru = [id_at_vanz=]+Alltrim(Str(tnIdAtVanz))
			lcSchema = [document W]
			lcOrder = []
			llAfisare = .F.
			GENCURSOR('poDocument','crsat',lcSelect,lcFiltru,lcSchema,lcOrder,llAfisare)
			loTherm.Update(40, "Citire document din baza de date...")
			poDocument.ca_baza1.afisare()
			loTherm.Update(55, "Citire document din baza de date...")
		
			lcFisier = gcTempPath + Alltrim(Str(tnNrAct,14,0)) + [_] + Alltrim(tcTip) + [.pdf]
			loTherm.Update(65, "Testare creare fisier...")
			If File(lcFisier)
				Try
					Delete File (lcFisier)
				Catch To oException
					lcFisier = Strtran(lcFisier,[.pdf],Ttoc(Datetime(),1)+[.pdf])
				Endtry
			Endif
			Select crsat
			loTherm.Update(85, "Creare fisier...")
			Strtofile(Document,lcFisier)
			loTherm.Update(95, "Deschidere fisier...")
			open_default_app(lcFisier)
			loTherm.Complete()
			Thisform.AlwaysOnTop = .T.
			Use In crsat
			Release poDocument,loTherm
		Endif
	ENDPROC

	PROCEDURE do_reset
		Thisform.ck_serie_factura.Value = 0
		Thisform.ck_data_factura.Value = 0
		Thisform.ck_data_factura.Value = 0
		Thisform.opt_incasate.Value = 1
		Thisform.do_cauta()
		
	ENDPROC

	PROCEDURE Init
		Lparameters tcTitlu
		Thisform.lb_TITLU_ALB_B121.Caption = tcTitlu
		Thisform.grd_facturi.cNr_factura.DynamicBackColor = [Iif(nratasamente<>0,Rgb(187,235,255),Rgb(255,255,255))]
		lcCursor = Thisform.grd_facturi.RecordSource
		Select (lcCursor)
		Go Top
		Thisform.Refresh()
		DoDefault()
		
	ENDPROC

	PROCEDURE Ck_data_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
	ENDPROC

	PROCEDURE Ck_nr_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
	ENDPROC

	PROCEDURE Ck_serie_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
		
	ENDPROC

	PROCEDURE grd_facturi.AfterRowColChange
		Lparameters nColIndex
		DoDefault()
		If This.RowColChange <> 2
			Select crsistoric
			Thisform.actualizeaza_grid2(id_fact)
		Endif
		
	ENDPROC

	PROCEDURE grd_facturi.cNr_factura.Text1.RightClick
		Select crsistoric
		If nratasamente <> 0
			Thisform.do_arata_meniu()
		Endif
	ENDPROC

	PROCEDURE opt_incasate.InteractiveChange
		Thisform.do_cauta()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_istoric_terti 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="grd_facturi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNr_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNr_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cData_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cData_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_val_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSuma_val_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNume_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cNume_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSerie_factura.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSerie_factura.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSold.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSold.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasatVal.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cIncasatVal.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSoldVal.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cSoldVal.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cTip.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_facturi.cTip.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_nr_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_serie_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_data_factura" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNr_incasare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNr_incasare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cData_incasare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cData_incasare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat_val.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cIncasat_val.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNume_val_inc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_incasari.cNume_val_inc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboSold" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboFacturi" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_arata_meniu
		*m: do_deschide_document
	*</DefinedPropArrayMethod>

	*<PropValue>
		cgridsortlist = grd_facturi
		DoCreate = .T.
		Height = 489
		Name = "frm_istoric_terti"
		Width = 610
		WindowState = 2
		_SHAPE1.Anchor = 10
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 613
		_SHAPE2.Anchor = 9
		_SHAPE2.Height = 29
		_SHAPE2.Left = 719
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Width = 60
		LB_TITLU_ALB_B121.Caption = "Istoric facturi"
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 580
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 526
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 43
	*</PropValue>

	ADD OBJECT 'But_reset_criterii1' AS but_reset_criterii WITH ;
		Anchor = 9, ;
		Left = 551, ;
		Name = "But_reset_criterii1", ;
		Top = 1
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cboFacturi' AS _combobox WITH ;
		BoundColumn = 2, ;
		BoundTo = .T., ;
		ColumnCount = 2, ;
		ColumnLines = .F., ;
		ColumnWidths = "100,0", ;
		Height = 24, ;
		Left = 490, ;
		Name = "cboFacturi", ;
		RowSource = "Facturi si incasari,1,Facturi,2,Incasari,3", ;
		RowSourceType = 1, ;
		Top = 39, ;
		Width = 120
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="combobox" />

	ADD OBJECT 'cboSold' AS _combobox WITH ;
		BoundColumn = 2, ;
		BoundTo = .T., ;
		ColumnCount = 2, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,0", ;
		Height = 24, ;
		Left = 288, ;
		Name = "cboSold", ;
		RowSource = "Toate facturile,1,Neincasate,2,Neincasate sau incasate partial,3,Incasate complet,4,Incasate partial,5", ;
		RowSourceType = 1, ;
		Top = 39, ;
		Width = 192
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="combobox" />

	ADD OBJECT 'Ck_data_factura' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = data_factura, ;
		Caption = "Data factura", ;
		Left = 194, ;
		Name = "Ck_data_factura", ;
		tip = D, ;
		Top = 42
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_nr_factura' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = nr_factura, ;
		Caption = "Nr.factura", ;
		Left = 112, ;
		Name = "Ck_nr_factura", ;
		Top = 42
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_serie_factura' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		camp_nume = serie_factura, ;
		Caption = "Serie factura", ;
		Left = 15, ;
		Name = "Ck_serie_factura", ;
		Top = 42
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grd_facturi' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 11, ;
		DeleteMark = .F., ;
		HeaderHeight = 38, ;
		Height = 279, ;
		Left = 11, ;
		Name = "grd_facturi", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "crsistoric", ;
		RowHeight = 19, ;
		Top = 69, ;
		Width = 581, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "nr_factura", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_factura", ;
		Column1.ReadOnly = .T., ;
		Column1.ToolTipText = 'Pentru a vizualiza documentele salvate in baza de date, trebuie sa faceti click dreapta pe coloana "Nr.factura" ( doar inregistrarile colorate au atasamente ).', ;
		Column1.Width = 82, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "data_factura", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_factura", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 95, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "suma_factura", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Format = "RK", ;
		Column3.InputMask = (get_mask(14,gnPa)), ;
		Column3.Name = "cSuma_factura", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 96, ;
		Column4.ColumnOrder = 7, ;
		Column4.ControlSource = "suma_val_factura", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Format = "RK", ;
		Column4.InputMask = (get_mask(14,gnPVal)), ;
		Column4.Name = "cSuma_val_factura", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 116, ;
		Column5.ColumnOrder = 10, ;
		Column5.ControlSource = "nume_val", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cNume_val", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 56, ;
		Column6.ColumnOrder = 1, ;
		Column6.ControlSource = "serie_factura", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cSerie_factura", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 95, ;
		Column7.ColumnOrder = 5, ;
		Column7.ControlSource = "incasat", ;
		Column7.FontName = "Arial", ;
		Column7.FontSize = 10, ;
		Column7.Format = "RK", ;
		Column7.InputMask = (get_mask(14,gnPa)), ;
		Column7.Name = "cIncasat", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 108, ;
		Column8.ColumnOrder = 6, ;
		Column8.ControlSource = "sold", ;
		Column8.Format = "RK", ;
		Column8.InputMask = (get_mask(14,gnPa)), ;
		Column8.Name = "cSold", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 113, ;
		Column9.ColumnOrder = 8, ;
		Column9.ControlSource = "incasat_val", ;
		Column9.Format = "RK", ;
		Column9.InputMask = (get_mask(14,gnPVal)), ;
		Column9.Name = "cIncasatVal", ;
		Column9.ReadOnly = .T., ;
		Column9.Width = 100, ;
		Column10.ColumnOrder = 9, ;
		Column10.ControlSource = "sold_val", ;
		Column10.Format = "RK", ;
		Column10.InputMask = (get_mask(14,gnPVal)), ;
		Column10.Name = "cSoldVal", ;
		Column10.ReadOnly = .T., ;
		Column10.Width = 99, ;
		Column11.ControlSource = "tip", ;
		Column11.Name = "cTip", ;
		Column11.ReadOnly = .T., ;
		Column11.Width = 21
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_facturi.cData_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data factura", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cData_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cIncasat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Achitat (lei)", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cIncasat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cIncasatVal.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Achitat (valuta)", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cIncasatVal.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cNr_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. document", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cNr_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cNume_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cNume_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSerie_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Serie document", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSerie_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSold.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Sold (lei)", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSold.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSoldVal.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Sold (valuta)", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSoldVal.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSuma_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare cu TVA (lei)", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSuma_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cSuma_val_factura.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare cu TVA (valuta)", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cSuma_val_factura.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_facturi.cTip.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_facturi.cTip.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari' AS _grdrow WITH ;
		Anchor = 14, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		HeaderHeight = 19, ;
		Height = 122, ;
		Left = 12, ;
		Name = "grd_incasari", ;
		Panel = 1, ;
		RecordSource = "crsincasari", ;
		RowHeight = 19, ;
		Top = 360, ;
		Width = 580, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "nr_incasare", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_incasare", ;
		Column1.Width = 117, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "TTOD(data_incasare)", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_incasare", ;
		Column2.Width = 103, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "incasat", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Format = "RK", ;
		Column3.InputMask = (get_mask(14,gnPa)), ;
		Column3.Name = "cIncasat", ;
		Column3.Width = 99, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "incasat_val", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Format = "RK", ;
		Column4.InputMask = (get_mask(14,gnPVal)), ;
		Column4.Name = "cIncasat_val", ;
		Column4.Width = 116, ;
		Column5.ColumnOrder = 5, ;
		Column5.ControlSource = "nume_val_inc", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cNume_val_inc", ;
		Column5.Width = 62
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_incasari.cData_incasare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data doc. achitat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cData_incasare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cIncasat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Achitat (lei)", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cIncasat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cIncasat_val.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Achitat (valuta)", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cIncasat_val.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cNr_incasare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. doc. achitat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cNr_incasare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_incasari.cNume_val_inc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valuta incasare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_incasari.cNume_val_inc.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE actualizeaza_grid2
		Lparameters tnIdFact
		If !Empty(tnIdFact)
			lcFiltru = [id_fact = ] + Alltrim(Str(tnIdFact))
		Else
			lcFiltru = [1=2]
		Endif
		Select crsincasari
		Set Filter To &lcFiltru
		Go Top
		Thisform.grd_incasari.Refresh()
		
	ENDPROC

	PROCEDURE do_arata_meniu
		Local lnCod,lnNrAct,lcSerie
		Select crsistoric
		lnCod =  cod
		lnNrAct = nr_factura
		lcSerie = Alltrim(Nvl(serie_factura,[]))
		If Used('crsmeniu')
			Use In crsmeniu
		Endif
		lcSql = [select a.id_at_vanz,a.tip,a.tip_doc from ] + gcS + [.vatasamente_vanzari a where a.cod = ] + Alltrim(Str(lnCod)) + [ order by a.tip]
		lnSucces = goExecutor.oExecute(lcSql,[crsmeniu])
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,16,"Eroare")
		Else
			Do Case
			Case Reccount('crsmeniu') = 1
				Thisform.do_deschide_document(crsmeniu.id_at_vanz,crsmeniu.tip_doc,lnNrAct)
			Case Reccount('crsmeniu')>0
				lcMeniu = []
				Select crsmeniu
				Scan
					lcMeniu = lcMeniu + [;] + Alltrim(tip_doc)
				Endscan
				x = xmenu(Substr(lcMeniu,2))
				Select crsmeniu
				Go x
				Thisform.do_deschide_document(crsmeniu.id_at_vanz,crsmeniu.tip_doc,lnNrAct)
			Otherwise
				amessagebox("Nu exista documente salvate in baza de date pentru factura "+lcSerie+" "+Alltrim(Str(lnNrAct,14,0)) + " !",48,"Atentie")
			Endcase
			Use In crsmeniu
		Endif
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		lnOptiuneSold = This.cboSold.Value && Toate facturile,1,Neincasate,2,Neincasate sau incasate partial,3,Incasate complet,4,Incasate partial,5
		lnOptiuneFacturi = this.cboFacturi.Value  && Facturi si incasari,1,Facturi,2,Incasari,3
		lcFiltru = [2=2]
		
		If Thisform.ck_serie_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_serie_factura.filtru_vfp
		Endif
		
		If Thisform.ck_nr_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_nr_factura.filtru_vfp
		Endif
		
		If Thisform.ck_data_factura.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_data_factura.filtru_vfp
		Endif
		
		DO CASE 
			CASE lnOptiuneFacturi = 1 && Facturi si incasari
				*
			CASE lnOptiuneFacturi = 2
				lcFiltru = lcFiltru + [ and tip = 'F'] && Facturi
			CASE lnOptiuneFacturi = 3
				lcFiltru = lcFiltru + [ and tip = 'A'] && Incasari
		ENDCASE 
				
		Do Case
			Case lnOptiuneSold = 1 && Toate Facturile
				*
			Case lnOptiuneSold = 2 && Neincasate
				lcFiltru = lcFiltru + [ and suma_factura = Nvl(sold,0)]
			Case lnOptiuneSold = 3 && Neincasate sau incasate partial
				lcFiltru = lcFiltru + [ and Nvl(sold,0) <> 0]
			Case lnOptiuneSold = 4 && Incasate complet
				lcFiltru = lcFiltru + [ and Nvl(sold,0) = 0]
			Case lnOptiuneSold = 5 && Incasate partial
				lcFiltru = lcFiltru + [ and Nvl(sold,0) <> 0 and suma_factura <> Nvl(sold,0)]		
		ENDCASE
		
		Select crsistoric
		Set Filter To (m.lcFiltru)
		Go Top
		Thisform.actualizeaza_grid2(id_fact)
		Thisform.grd_facturi.Refresh()
		
	ENDPROC

	PROCEDURE do_deschide_document
		Lparameters tnIdAtVanz,tcTip,tnNrAct
		If !Empty(tnIdAtVanz)
			Private poDocument
			Store "" To poDocument
			If Used('crsat')
				Use In crsat
			Endif
		
			Thisform.AlwaysOnTop = .F.
			Local loTherm
			loTherm = Newobject("_thermometer","_therm","","Citire document din baza de date...")
			loTherm.Show()
		
			lcSelect = [select document from ] + gcS + [.atasamente_vanzari where ]
			lcFiltru = [id_at_vanz=]+Alltrim(Str(tnIdAtVanz))
			lcSchema = [document W]
			lcOrder = []
			llAfisare = .F.
			GENCURSOR('poDocument','crsat',lcSelect,lcFiltru,lcSchema,lcOrder,llAfisare)
			loTherm.Update(40, "Citire document din baza de date...")
			poDocument.ca_baza1.afisare()
			loTherm.Update(55, "Citire document din baza de date...")
		
			lcFisier = gcTempPath + Alltrim(Str(tnNrAct,14,0)) + [_] + Alltrim(tcTip) + [.pdf]
			loTherm.Update(65, "Testare creare fisier...")
			If File(lcFisier)
				Try
					Delete File (lcFisier)
				Catch To oException
					lcFisier = Strtran(lcFisier,[.pdf],Ttoc(Datetime(),1)+[.pdf])
				Endtry
			Endif
			Select crsat
			loTherm.Update(85, "Creare fisier...")
			Strtofile(Document,lcFisier)
			loTherm.Update(95, "Deschidere fisier...")
			open_default_app(lcFisier)
			loTherm.Complete()
			Thisform.AlwaysOnTop = .T.
			Use In crsat
			Release poDocument,loTherm
		Endif
	ENDPROC

	PROCEDURE do_reset
		Thisform.ck_serie_factura.Value = 0
		Thisform.ck_data_factura.Value = 0
		Thisform.ck_data_factura.Value = 0
		Thisform.opt_incasate.Value = 1
		Thisform.do_cauta()
		
	ENDPROC

	PROCEDURE Init
		Lparameters tcTitlu
		DoDefault()
		
		Thisform.lb_TITLU_ALB_B121.Caption = tcTitlu
		Thisform.grd_facturi.cNr_factura.DynamicBackColor = [Iif(nratasamente<>0,Rgb(187,235,255),Rgb(255,255,255))]
		
		Select crsIstoric
		Go Top
		Thisform.actualizeaza_grid2(id_fact)
		
		
	ENDPROC

	PROCEDURE cboFacturi.Valid
		thisform.do_cauta()
	ENDPROC

	PROCEDURE cboSold.Valid
		thisform.do_cauta()
	ENDPROC

	PROCEDURE Ck_data_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
	ENDPROC

	PROCEDURE Ck_nr_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
	ENDPROC

	PROCEDURE Ck_serie_factura.InteractiveChange
		DoDefault()
		Thisform.do_cauta()
		
	ENDPROC

	PROCEDURE grd_facturi.AfterRowColChange
		Lparameters nColIndex
		DoDefault()
		If This.RowColChange <> 2
			Select crsistoric
			Thisform.actualizeaza_grid2(id_fact)
		Endif
		
	ENDPROC

	PROCEDURE grd_facturi.cNr_factura.Text1.RightClick
		Select crsistoric
		If nratasamente <> 0
			Thisform.do_arata_meniu()
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_jurnal_plati_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="Shape4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtdata1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtdata2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_filtru_data" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_afis" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_recap" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: pregateste_date		&& selecteaza datele necesare de pe serverul Oracle
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 235
		Name = "frm_jurnal_plati_incasari"
		Width = 300
		_shape1.Name = "_shape1"
		_shape1.ZOrderSet = 4
		_shape2.Height = 29
		_shape2.Left = 213
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 87
		_shape2.ZOrderSet = 5
		Lb_titlu_alb_b121.Caption = "Jurnal plati/incasari"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.ZOrderSet = 6
		BUT_TERMIN1.Left = 270
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 7
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

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

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

	ADD OBJECT 'Ck_filtru_data' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = dataact, ;
		Caption = "Data", ;
		Left = 73, ;
		Name = "Ck_filtru_data", ;
		tip = D, ;
		Top = 96, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "_", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 119, ;
		Name = "Label1", ;
		TabIndex = 8, ;
		Top = 57, ;
		Width = 9, ;
		ZOrderSet = 11
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Filtrare:", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 26, ;
		Name = "Label2", ;
		TabIndex = 8, ;
		Top = 93, ;
		Width = 44, ;
		ZOrderSet = 12
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		Caption = "Perioada de referinta", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 20, ;
		Name = "Label3", ;
		TabIndex = 8, ;
		Top = 37, ;
		Width = 126, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label4' AS label WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		Caption = "Afiseaza", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 19, ;
		Name = "Label4", ;
		TabIndex = 8, ;
		Top = 133, ;
		Width = 59, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		Caption = "Cu recapitulatie", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 152, ;
		Name = "Label5", ;
		TabIndex = 8, ;
		Top = 132, ;
		Width = 99, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'opt_afis' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 2, ;
		Height = 52, ;
		Left = 18, ;
		Name = "opt_afis", ;
		SpecialEffect = 1, ;
		TabIndex = 11, ;
		Top = 154, ;
		Value = 1, ;
		Width = 65, ;
		ZOrderSet = 14, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Plati", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 1, ;
		Option1.Width = 37, ;
		Option2.AutoSize = .T., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "Incasari", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Height = 18, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 29, ;
		Option2.Width = 55
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'opt_recap' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 2, ;
		Height = 52, ;
		Left = 150, ;
		Name = "opt_recap", ;
		SpecialEffect = 1, ;
		TabIndex = 11, ;
		Top = 155, ;
		Value = 1, ;
		Width = 100, ;
		ZOrderSet = 16, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Pe parteneri", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 1, ;
		Option1.Width = 76, ;
		Option2.AutoSize = .T., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "Pe responsabili", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Height = 18, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 29, ;
		Option2.Width = 90
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		Height = 79, ;
		Left = 12, ;
		Name = "Shape2", ;
		Top = 143, ;
		Width = 109, ;
		ZOrderSet = 2
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackStyle = 0, ;
		Height = 79, ;
		Left = 144, ;
		Name = "Shape3", ;
		Top = 143, ;
		Width = 145, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape4' AS shape WITH ;
		BackStyle = 0, ;
		Height = 78, ;
		Left = 12, ;
		Name = "Shape4", ;
		Top = 48, ;
		Width = 235, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'txtdata1' AS textbox WITH ;
		BorderColor = 128,128,128, ;
		ControlSource = "", ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 25, ;
		Name = "txtdata1", ;
		SpecialEffect = 1, ;
		TabIndex = 10, ;
		Top = 61, ;
		Width = 88, ;
		ZOrderSet = 9
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtdata2' AS textbox WITH ;
		BorderColor = 128,128,128, ;
		ControlSource = "", ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 133, ;
		Name = "txtdata2", ;
		SpecialEffect = 1, ;
		TabIndex = 10, ;
		Top = 61, ;
		Width = 88, ;
		ZOrderSet = 10
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE do_excel
		Local lcCursor,llplati,llresp
		lcCursor = Thisform.pregateste_date()
		
		llplati = Iif(Thisform.opt_afis.Value=1,.T.,.F.)
		llresp = Iif(Thisform.opt_recap.Value=1,.F.,.T.)
		If !Used(lcCursor)
			Messagebox('Nu s-a creat tabelul ' + lcCursor,0+48,_Screen.Caption)
			Return
		Endif
		Select (lcCursor)
		
		*!*	SET DEFAULT TO &gcSchemaPath
		*!*	CD &gcSchemaPath
		*!*	IF !DIRECTORY('&gcSchemaPath\jurnal_incasplati')
		*!*		MD jurnal_incasplati
		*!*	ENDIF
		*!*	lcFile=gcSchemaPath+'\jurnal_incasplati\jurnal_'+SYS(2)+'.XLS'
		lcFile = gcTempPath + [jurnal_incasplati]+Sys(2)+[.XLS]
		If tlresp
			Select tip, cnume As responsabil, cpartener As partener, ;
				suma5112 + suma5121 + suma5311 + compensari + diverse As Total, suma5112, suma5121, suma5311, compensari, diverse, ;
				contp As Cont, acont As analitic ;
				from (lcCursor) Order By 1,2  Into Cursor query_avans
		Else
			Select tip, cpartener As partener, ;
				suma5112 + suma5121 + suma5311 + compensari + diverse As Total, suma5112, suma5121, suma5311, compensari, diverse, ;
				contp As Cont, acont As analitic ;
				from (lcCursor) Order By 1,2 Into Cursor query_avans
		Endif
		
		Select query_avans
		
		Copy To (lcFile) Type Xls
		Use In (lcCursor)
		
		OPEN_DEFAULT_APP(lcFile)
		
		
	ENDPROC

	PROCEDURE do_listare
		Local lcCursor,llplati,llresp,lcRaport,llPageBreak, lcRaportTemp
		Local lcNume, lcReportTempPath, lcTempFile, lcTempIndex, lctitlu
		Local llMultiPreview
		*:Global buton
		llPageBreak = .F.
		lcRaportTemp = ""
		llMultiPreview = .T.
		Private poCauta
		poCauta = Null
		lcCursor = Thisform.pregateste_date()
		If Empty(lcCursor)
			Return
		Endif
		
		
		Private pcfelrap,pctitlu,pcperioada,pcdataora
		Store '' To pcfelrap,pctitlu,pcperioada,pcdataora
		
		llplati = Iif(Thisform.opt_afis.Value=1,.T.,.F.)
		llresp = Iif(Thisform.opt_recap.Value=1,.F.,.T.)
		
		Select (lcCursor)
		Delete All For SUMA5121=0 And suma5112=0 And suma5311=0 And compensari=0 And diverse=0
		lcTempIndex = Addbs(gcTempPath) + "incasplati.idx"
		Index On cnume +Alltrim(Str(tip)) To (m.lcTempIndex)
		
		&&preluare ora de pe oracle server:
		*!*	STORE 0 to pnsucces
		*!*	pcexec = [select to_char(SYSdate,'dd/mm/yyyy hh:mi:ss AM') as dataora from dual]
		*!*	pcCursor = [dataora_cursor]
		*!*	pnsucces = goExecutor.oExecute(pcexec,pcCursor)
		*!*	IF (pnsucces != 0)
		*!*		SELECT dataora_cursor
		*!*		pcdataora = dataora_cursor.dataora
		*!*		USE IN dataora_cursor
		*!*	ENDIF
		Thisform.AlwaysOnTop = .F.
		Select (lcCursor)
		If Reccount(lcCursor) > 0
			pcperioada = [Perioada de referinta:] + Dtoc(pdData1)+[ - ]+Dtoc(pdData2)
			lcRaport =[jurnal_plati_incasari]
		
			If llplati
				pcfelrap=[platit]
				lctitlu= [Jurnal plati]
			Else
				pcfelrap=[incasat]
				lctitlu= [Jurnal incasari]
			Endif
		
			pctitlu = ceretitlu_rap('Titlul Raportului',lctitlu)
		
			pcdataora = get_ora(2)
			If llresp
				&& se listeaza pe responsabili
				If Isnull(poCauta)
					lcNume = '<TOATE INREGISTRARILE>'
				Else
					lcNume=Alltrim(poCauta.nume)
				Endif
		
				If lcNume = '<TOATE INREGISTRARILE>' Or Empty(lcNume)
					*!*			DO danu WITH "Se listeaza cate un responsabil pe pagina ?"
					buton = 7 - aMESSAGEBOX("Se listeaza cate un responsabil pe pagina?",4+32,"Confirmare")
					If buton = 1
						llPageBreak = .T.
					Endif
				Endif
				lcReportTempPath = Addbs(gcAppPath) + "rapoarte\jurnal_plati_incasari.frx"
				Use (m.lcReportTempPath) In 0 Alias rap_incasplati Shared
				Select rap_incasplati
				lcTempFile = Addbs(gcTempPath) + "temp_jurnal_plati_incasari.frx"
				Copy To (m.lcTempFile)
				Use In rap_incasplati
		
				Use (m.lcTempFile) In 0 Shared Alias rap_incasplati
				Select rap_incasplati
				Locate For objCode = 3 And 'cnume'$Expr
				If Found()
					If Flock()
						Replace PageBreak With llPageBreak
						Unlock
					Endif
				Endif
				Use In rap_incasplati
		
				Select (lcCursor)
				*!* 07.06.2011
				*!*			Report Form (m.lcTempFile) To Printer Prompt Preview
				goExport.export2frx(m.lcCursor, m.lcTempFile, , , , , , llMultiPreview, , )
				*!* 07.06.2011 ^
				Delete File Forceext(m.lcTempFile,'*')
		
				If lcNume = '<TOATE INREGISTRARILE>'
					pctitlu= pctitlu +" "+ Chr(13)+Chr(10)+ '- Recapitulatie -'
					Select (lcCursor)
					Delete All For tip = 1
					*!* 07.06.2011
					*!*				Report Form (lcRaport) To Printer Prompt Preview
					goExport.export2frx(m.lcCursor, m.lcRaport, , , , , , llMultiPreview, , )
					*!* 07.06.2011 ^
				Endif
			Else
				*!* 07.06.2011
				*!*				Report Form (lcRaport) To Printer Prompt Preview
				goExport.export2frx(m.lcCursor, m.lcRaport, , , , , , llMultiPreview, , )
				*!* 07.06.2011 ^
			Endif
		Else
			aMESSAGEBOX("Nu exista inregistrari pentru listare!",48,"Atentie")
		Endif
		
		Use In (lcCursor)
		Store Null To poCauta
		Thisform.AlwaysOnTop = .T.
		
		 
	ENDPROC

	PROCEDURE pregateste_date		&& selecteaza datele necesare de pe serverul Oracle
		*!* 04.11.2010
		*!* lcIncasari473: 473 = 4111 incasari conpress numerar chioscuri
		
		*!* 20.12.2010
		*!* marius.mutu
		*!* sa nu apara 5311 = 473, pentru ca le-am luat in considerare la 473 = 4111
		*!* sa nu apara 473 = 4111 la compensari
		*!* #2834
			
		*!* 21.06.2011
		*!* marius.mutu
		*!* se pot selecta inregistrari din orice perioada, nu numai din luna curenta
		*!* #3054
		
		Local llresp,llplati,lccond, lcNume, lcCompensare, lcFiltruData
		Local lcCursor, lcCursor1, lcIncasari473, lcSelect, lcSelect1, lccompensare_cf, lccondcomp, ldData1
		Local ldData2, lnId_part, lnId_responsabil, lnSucces, lnSucces1
		*:Global poCauta, tlresp
		*!* poCauta - variabila privata definita in do_listare, do_excel
		llplati = Iif(Thisform.opt_afis.Value=1,.T.,.F.)
		llresp = Iif(Thisform.opt_recap.Value=1,.F.,.T.)
		tlresp = llresp
		
		If llresp
			&& cautare responsabil
			poCauta = CautPartenerContabilitate(GetHash([cTitlu=>Alegeti responsabilul??lAllInList=>1]))
		Else
			&& cautare partener
			poCauta = CautPartenerContabilitate(GetHash([cTitlu=>Alegeti partenerul??lAllInList=>1]))
		Endif
		
		
		lccond = [1=1]
		lcNume = Alltrim(poCauta.denumire)
		If Empty(lcNume)
			Store NULL To poCauta
			Return []
		Endif
		
		If (lcNume # '<TOATE INREGISTRARILE>')
			If llresp	&& daca se face listarea pe responsabili
				lnId_responsabil = poCauta.id_part
				lccond = [id_responsabil = ] + Alltrim(Str(lnId_responsabil))
			Else
				lnId_part = poCauta.id_part
				lccond = Iif(llplati,[id_partd = ],[id_partc = ]) + Alltrim(Str(lnId_part))
			Endif
		Endif
		
		&& compensare intre facturi de clieni si furnizori
		*!* 20.12.2010
		*!*	lccompensare_cf=[(scd in ('401','404','462', '473') AND scc in ('4111','461'))]
		lccompensare_cf=[(scd in ('401','404','462') AND scc in ('4111','461'))]
		*!* 20.12.2010 ^
		lcIncasari473=[(scd = '473' AND scc = '4111')] && incasari chioscuri conpress 473 = 4111
		lcfiltrudata = Iif(!Empty(Thisform.ck_filtru_data.filtru),Thisform.ck_filtru_data.filtru,[ and 1=1])
		*!* 21.06.2011
		ldData1 = this.txtdata1.Value 
		ldData2 = this.txtdata2.Value 
		
		IF YEAR(m.ldData1) = YEAR(m.ldData2)
			lcFiltruData = lcFiltruData + [ and an = ] + ALLTRIM(STR(YEAR(m.ldData1)))
			IF MONTH(m.ldData1) = MONTH(m.ldData2)
				lcFiltruData = lcFiltruData + [ and luna = ] + ALLTRIM(STR(month(m.ldData1)))		
			ELSE 
				lcFiltruData = lcFiltruData + [ and luna between ] + ALLTRIM(STR(month(m.ldData1))) + [ and ] + ALLTRIM(STR(month(m.ldData2)))
			ENDIF 	
		ELSE 
			lcFiltruData = lcFiltruData + [ and an between ] + ALLTRIM(STR(YEAR(m.ldData1))) + [ and ] + + ALLTRIM(STR(YEAR(m.ldData2)))	
		ENDIF 		
		*!* 21.06.2011 ^
		
		IF llplati  
		    && jurnal plati
			lccond = lccond + [ and (substr(scc,1,1) = '5' OR ] + lccompensare_cf + [)]
			lccondcomp = [(substr(scc,1,1)='5' AND (NVL(INSTR(Upper(trim(partc)),'COMPENSARI'),0)<>0 ] + ;
			[OR NVL(INSTR(Upper(trim(explicatia)),'COMPENS'),0)<>0))]            
		          
			lcSelect = [select nresp as cnume,partd as cpartener,scd as contp,ascd as acont,1 as tip,] + ;
			[sum(decode(SUBSTR(scc,1,3),'511',suma,0)) as suma5112,] + ;
		  	[sum(case when (SUBSTR(scc,1,3)='512' AND NVL(INSTR(Upper(trim(partc)),'COMPENSARI'),0)=0 ] +;
		  	[AND NVL(INSTR(Upper(trim(explicatia)),'COMPENS'),0)=0) then suma else 0 end) as suma5121,] + ;
		  	[sum(case when (SUBSTR(scc,1,3)='531' AND NVL(INSTR(Upper(trim(partc)),'COMPENSARI'),0)=0 ] +;
		  	[AND NVL(INSTR(Upper(trim(explicatia)),'COMPENS'),0)=0) then suma else 0 end) as suma5311,] + ;	
		  	[sum(case when (] + lccompensare_cf + [ OR ] + lccondcomp + [) then suma else 0 end) as compensari,] + ;
		  	[sum(case when (SUBSTR(scc,1,1)='5' AND SUBSTR(scc,1,3) NOT IN ('512','511','531') ] + ;
		  	[) then suma else 0 end) as diverse  from ] + ; 
		  	[ (select ] + IIF(llresp,[nresp],[' '])+[ as nresp,NVL(partd,lpad(chr(32),50,chr(32))) as partd,] +;		  	
		  	[scd,ascd,scc,partc,explicatia,suma from ] + ;
			[vact  where ] + lccond + lcfiltrudata + [ and SUBSTR(scc,1,3)<>'581'] +;
			[ and SUBSTR(scd,1,3)<>'581' ] + ;
			Iif(!IsNull(gnIdSucursala),[ and NVL(id_sucursala,-99) = NVL(]+ALLTRIM(STR(gnIdSucursala))+[,-99)],[]) + [)] + ;
			[ group by nresp,partd,scd,ascd order by 1,5,3,4,2]           
		
		ELSE
			&& jurnal incasari
			*!* 04.11.2010
			*!* lcIncasari473: 473 = 4111 incasari conpress numerar chioscuri
			*!* 20.12.2010
			*!* !(substr(scd,1,1) = '5' and scc = '473')
				
			lccond = lccond + [ and (substr(scd,1,1) = '5' OR ] + lccompensare_cf + [ OR ] + lcIncasari473 + [) and not (substr(scd,1,1) = '5' and scc = '473') ]
			lccondcomp = [(substr(scd,1,1)='5' AND (NVL(INSTR(Upper(trim(partd)),'COMPENSARI'),0)<>0 ] + ;
			[OR NVL(INSTR(Upper(trim(explicatia)),'COMPENSARI'),0)<>0))]            
		          
			lcSelect = [select nresp as cnume,partc as cpartener,scc as contp,ascc as acont,1 as tip,] + ;
			[sum(decode(SUBSTR(scd,1,3),'511',suma,0)) as suma5112,] + ;
		  	[sum(case when (SUBSTR(scd,1,3)='512' AND NVL(INSTR(Upper(trim(partd)),'COMPENSARI'),0)=0 ] +;
		  	[AND NVL(INSTR(Upper(trim(explicatia)),'COMPENS'),0)=0) then suma else 0 end) as suma5121,] + ;
		  	[sum(case when ((SUBSTR(scd,1,3)='531' OR scd = '473') AND NVL(INSTR(Upper(trim(partd)),'COMPENSARI'),0)=0 ] +;
		  	[AND NVL(INSTR(Upper(trim(explicatia)),'COMPENS'),0)=0) then suma else 0 end) as suma5311,] + ;	
		  	[sum(case when (] + lccompensare_cf + [ OR ] + lccondcomp + [) then suma else 0 end) as compensari,] + ;
		  	[sum(case when (SUBSTR(scd,1,1)='5' AND SUBSTR(scd,1,3) NOT IN ('512','511','531') ] + ;
		  	[) then suma else 0 end) as diverse  from ] + ;  		  	
		  	[ (select ] + IIF(llresp,[nresp],[' '])+[ as nresp,NVL(partc,lpad(chr(32),50,chr(32))) as partc,] +;		  	
		  	[scc,ascc,scd,partd,explicatia,suma from ] + ;
			[vact  where ] + lccond  + lcfiltrudata + [ and SUBSTR(scc,1,3)<>'581'] +;
			[ and SUBSTR(scd,1,3)<>'581' ] + ;
			Iif(!IsNull(gnIdSucursala),[ and NVL(id_sucursala,-99) = NVL(]+ALLTRIM(STR(gnIdSucursala))+[,-99)],[]) + [)] + ;
			[ group by nresp,partc,scc,ascc order by 1,3,4,2,5]           
			*!* 04.11.2010 ^
		ENDIF
		
		
		STRTOFILE(lcSelect,"c:\select1.txt")
		
		lcCursor = 'incasplati'
		lnSucces = goExecutor.oExecute(lcSelect,lcCursor)
		If lnSucces < 0
			aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
			Return
		Endif
		
		Select cnume,contp + Iif(Isnull(acont),'','.'+ acont) As contana, acont, contp, 2 As tip, ;
			sum(suma5112) As suma5112, Sum(suma5121) As suma5121, ;
			sum(suma5311) As suma5311, Sum(compensari) As compensari, Sum(diverse) As diverse ;
			FROM incasplati;
			INTO Cursor recapit ;
			GROUP By 1,2,3,4,5
		
		lcSelect1 = [select cont,acont,explicatie from ] + gcS + [.vnom_plcont where an=] + Alltrim(Str(gnan))
		lcCursor1 = [plcont]
		lnSucces1 = goExecutor.oExecute(lcSelect1,lcCursor1)
		If lnSucces1 < 0
			aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
			Return
		Endif
		
		Select r.*, p.explicatie As cpartener ;
			FROM recapit r Left Join plcont p On r.contp = p.Cont And ;
			IIF(Isnull(r.acont) And Isnull(p.acont),.T.,r.acont = p.acont) ;
			INTO Cursor tvars
		Use In plcont
		
		Select * From incasplati Into Cursor incas_plati Readwrite
		Use In incasplati
		
		Select incas_plati
		Append From Dbf("tvars")
		Use In tvars
		
		Return [incas_plati]
		 
	ENDPROC

	PROCEDURE Ck_filtru_data.InteractiveChange
		
		DODEFAULT()
		IF this.value = 1
			pdData1 = CTOD(this.cvaloare1)
			pdData2 = CTOD(this.cvaloare2)
		ELSE
			pdData1 = pdinit1
			pdData2 = pdinit2
		ENDIF	
		thisform.refresh
	ENDPROC

	PROCEDURE Ck_filtru_data.Valid
		*!* 21.06.2011
		*!* marius.mutu
		*!* se pot selecta inregistrari din orice perioada, nu numai din luna curenta
		*!* #3054
		
		Local lddata1,lddata2
		lddata1 = Ctod(This.cvaloare1)
		lddata2 = Ctod(This.cvaloare2)
		If This.Value = 0
			Return
		Endif
		
		*!* 21.06.2011
		If lddata1 <= lddata2 && AND BETWEEN(lddata1,pdinit1,pdinit2) AND BETWEEN(lddata2,pdinit1,pdinit2)
			Return .T.
		Else
			pdData1 = pdinit1
			pdData2 = pdinit2
			This.Value = 0
			Thisform.Refresh
			Wait Window "Date incorecte!"
			Return .F.
		Endif
		*!* 21.06.2011 ^
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_notificari 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="But_listare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri.Column1._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="text" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_select_adv1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: update_ireg
		*p: cordinegrid1
		*p: nid_part
		*p: odate
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton1 = 
		cbuton2 = but_listare1;but_excel1
		cordinegrid1 = 
		DoCreate = .T.
		Height = 503
		Name = "frm_notificari"
		nid_part = -1
		odate = 
		Width = 664
		WindowState = 2
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 670
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 564
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 108
		Lb_titlu_alb_b121.Caption = "NOTIFICÃRI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.FontSize = 11
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 634
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_listare2' AS but_listare WITH ;
		Anchor = 9, ;
		caction = do_listare, ;
		Left = 602, ;
		Name = "But_listare2", ;
		TabIndex = 4, ;
		ToolTipText = "Listare(CTRL+P)", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Anchor = 9, ;
		Left = 569, ;
		Name = "But_salveaza1", ;
		TabIndex = 6, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_select_adv1' AS cmd_select_adv WITH ;
		Anchor = 6, ;
		ccoloana = ales, ;
		cgrid = Thisform.Grid_parteneri, ;
		Left = 12, ;
		Name = "Cmd_select_adv1", ;
		Top = 244
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Grid_parteneri' AS grid WITH ;
		Anchor = 15, ;
		ColumnCount = 1, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		Height = 204, ;
		Left = 12, ;
		Name = "Grid_parteneri", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordMark = .T., ;
		TabIndex = 1, ;
		Top = 36, ;
		Width = 634, ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .F., ;
		Column1.Sparse = .F., ;
		Column1.Width = 25
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'Grid_parteneri.Column1._checkbox1' AS _checkbox WITH ;
		Alignment = 2, ;
		Caption = "", ;
		Centered = .T., ;
		Left = 37, ;
		Name = "_checkbox1", ;
		ReadOnly = .F., ;
		Top = 23
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Grid_parteneri.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Ales", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.Grid_parteneri, ;
		Left = 480, ;
		Name = "Gridextra1", ;
		Top = 252
		*< END OBJECT: ClassLib="..\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'text' AS _editbox WITH ;
		Anchor = 14, ;
		Height = 216, ;
		Left = 12, ;
		Name = "text", ;
		TabIndex = 3, ;
		Top = 276, ;
		Width = 636
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="editbox" />
	
	PROCEDURE do_listare
		Private pcMesaj
		Local lcCursor
		lcCursor = [crsraport]
		pcMesaj = Thisform.Text.Value
		Select nume,id_part,adresa,cod_fiscal,reg_comert From (Thisform.grid_parteneri.RecordSource) Where ales = 1 ;
			order By nume ;
			into Cursor (lcCursor)
		Thisform.AlwaysOnTop = .F.
		goExport.export2frx(lcCursor,[notificare])
		Thisform.AlwaysOnTop = .T.
		If Used(lcCursor)
			Use In (lcCursor)
		Endif
		Release lcCursor,pcMesaj
	ENDPROC

	PROCEDURE do_salvare
		Private pcText
		pcText = Thisform.Text.Value
		If !Empty(pcText) And !Empty(Nvl(This.odate.id_notificare,0))
			If aMessagebox("Doriti sa salvati textul notificarii in baza de date?",32+4,"Confirmare salvare") = 6
				lcSql = [update notificari set text = ?pcText where id_notificare = ] + Alltrim(Str(This.odate.id_notificare))
				If goExecutor.oExecuta(lcSql)
					aMessagebox("Textul notificarii a fost salvat in baza de date!",64,"Info salvare")
				Endif
			Endif
		Endif
		Release pcText
		
	ENDPROC

	PROCEDURE Init
		Lparameters toDate
		Thisform.odate = toDate
		Thisform.Text.Value = Thisform.odate.Text
		DoDefault()
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		Thisform.gridextra1.setup()
	ENDPROC

	PROCEDURE update_ireg
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_notificari_extra 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="But_listare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cTitlu.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cTitlu.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cIdNotificare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cIdNotificare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cOrdine.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cOrdine.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cUtilizator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cUtilizator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cDataOra.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdNotificari.cDataOra.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="text" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="spnOrdine" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblOrdine" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtTitlu" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_label1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: update_ireg
		*p: caliasparteneri
		*p: cordinegrid1
		*p: nidnotificare
		*p: nid_part
		*p: odate
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		caliasparteneri = 
		cbuton1 = 
		cbuton2 = but_listare1;but_excel1
		cordinegrid1 = 
		DoCreate = .T.
		Height = 503
		Name = "frm_notificari_extra"
		nidnotificare = 0
		nid_part = -1
		odate = 
		Width = 664
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="nidnotificare" display="nIdNotificare"/>
			<memberdata name="caliasparteneri" display="cAliasParteneri"/>
		</VFPData>
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 670
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 564
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 108
		Lb_titlu_alb_b121.Caption = "NOTIFICÃRI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.FontSize = 11
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 10
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 634
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_label1' AS _label WITH ;
		Caption = "Titlu", ;
		FontBold = .T., ;
		Height = 17, ;
		Left = 12, ;
		Name = "_label1", ;
		TabIndex = 12, ;
		Top = 222, ;
		Width = 26
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT 'But_listare2' AS but_listare WITH ;
		Anchor = 9, ;
		caction = do_listare, ;
		Left = 605, ;
		Name = "But_listare2", ;
		TabIndex = 6, ;
		ToolTipText = "Listare(CTRL+P)", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Anchor = 9, ;
		Left = 546, ;
		Name = "But_salveaza1", ;
		TabIndex = 4, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 9, ;
		Left = 576, ;
		Name = "But_sterge1", ;
		TabIndex = 7, ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grdNotificari' AS grid WITH ;
		Anchor = 0, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		Height = 176, ;
		Left = 12, ;
		Name = "grdNotificari", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordMark = .T., ;
		RecordSource = "cNotificari", ;
		TabIndex = 9, ;
		Top = 36, ;
		Width = 468, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "titlu", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cTitlu", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 217, ;
		Column2.ColumnOrder = 1, ;
		Column2.ControlSource = "id_notificare", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cIdNotificare", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 35, ;
		Column3.ControlSource = "ordine", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "cOrdine", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 32, ;
		Column4.ControlSource = "utilizator", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Name = "cUtilizator", ;
		Column4.ReadOnly = .T., ;
		Column5.ControlSource = "dataora", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Name = "cDataOra", ;
		Column5.ReadOnly = .T.
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'grdNotificari.cDataOra.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Dataora", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdNotificari.cDataOra.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdNotificari.cIdNotificare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Id", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdNotificari.cIdNotificare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdNotificari.cOrdine.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Ordine", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdNotificari.cOrdine.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdNotificari.cTitlu.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Notificare", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdNotificari.cTitlu.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grdNotificari.cUtilizator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Utilizator", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdNotificari.cUtilizator.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grdNotificari, ;
		Left = 480, ;
		Name = "Gridextra1", ;
		Top = 192
		*< END OBJECT: ClassLib="..\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'lblOrdine' AS _label WITH ;
		Anchor = 8, ;
		Caption = "Ordine", ;
		FontBold = .T., ;
		Left = 544, ;
		Name = "lblOrdine", ;
		TabIndex = 11, ;
		Top = 220
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT 'spnOrdine' AS _spinner WITH ;
		Anchor = 8, ;
		ControlSource = "cNotificari.ordine", ;
		Height = 24, ;
		Left = 588, ;
		Name = "spnOrdine", ;
		TabIndex = 2, ;
		Top = 216, ;
		Width = 59
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="spinner" />

	ADD OBJECT 'text' AS _editbox WITH ;
		Anchor = 15, ;
		ControlSource = "cNotificari.text", ;
		Height = 240, ;
		Left = 12, ;
		Name = "text", ;
		TabIndex = 3, ;
		Top = 247, ;
		Width = 636
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="editbox" />

	ADD OBJECT 'txtTitlu' AS _textbox WITH ;
		ControlSource = "cNotificari.titlu", ;
		Format = "K", ;
		Height = 23, ;
		Left = 48, ;
		Name = "txtTitlu", ;
		TabIndex = 1, ;
		Top = 219, ;
		Width = 432
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />
	
	PROCEDURE do_adauga
		SELECT cNotificari
		APPEND BLANK 
		REPLACE titlu WITH "_Notificare noua", ordine WITH 999, utilizator WITH m.gcUserNameApp, dataora WITH DATETIME(), id_notificare WITH 0
		thisform.Refresh
		thisform.txtTitlu.SetFocus()
	ENDPROC

	PROCEDURE do_listare
		PRIVATE pcMesaj
		LOCAL lcCursor, lcSelect
		LOCAL lcAliasParteneri
		lcSelect = SELECT()
		lcCursor = [crsraport]
		pcMesaj = THISFORM.TEXT.VALUE
		SET STEP ON 
		lcAliasParteneri = THIS.cAliasParteneri
		
		SELECT nume, id_part, adresa, cod_fiscal, reg_comert, telefon,email FROM (m.lcAliasParteneri) ;
			ORDER BY nume ;
			INTO CURSOR (m.lcCursor)
		
		THISFORM.ALWAYSONTOP = .F.
		goExport.export2frx(lcCursor, [notificare], , , , , , .T.)
		THISFORM.ALWAYSONTOP = .T.
		USE IN (SELECT(m.lcCursor))
		
		RELEASE lcCursor, pcMesaj
		SELECT (m.lcSelect)
	ENDPROC

	PROCEDURE do_salvare
		PRIVATE pcText, pcTitlu
		LOCAL lcSql, lnIdNotificare, lnOrdine
		LOCAL llSucces
		llSucces  = .F.
		pcText = THISFORM.TEXT.VALUE
		pcTitlu = ALLTRIM(thisform.txtTitlu.Value)
		lnIdNotificare = NVL(cNotificari.id_notificare, 0)
		lnOrdine = THISFORM.spnOrdine.VALUE
		this.but_salveaza1.SetFocus()
		IF !EMPTY(m.pcText)
			IF EMPTY(m.lnIdNotificare)
				PRIVATE pnIdNotificare
				pnIdNotificare = 0
				lcSql = [insert into notificari (titlu, id_util, ordine) values (?pcTitlu, ?gnIdUtil, 999) returning id_notificare into ?@pnIdNotificare]
				llSucces = goExecutor.oExecuta(m.lcSql)
				IF m.llSucces
					SELECT cNotificari
					REPLACE id_notificare WITH m.pnIdNotificare
				ENDIF
			ELSE
				IF aMessagebox("Doriti sa salvati notificarea in baza de date?", 32 + 4, "Confirmare salvare") = 6
					lcSql = [update notificari set text = ?pcText, ordine = ] + ALLTRIM(STR(m.lnOrdine)) + [ where id_notificare = ] + ALLTRIM(STR(m.lnIdNotificare))
					llSucces = goExecutor.oExecuta(m.lcSql)
				ENDIF
			ENDIF
			IF m.llSucces
				aMessagebox("Notificarea a fost salvata in baza de date!", 64, "Info salvare")
			ENDIF
		ENDIF
		RELEASE pcText
		
	ENDPROC

	PROCEDURE do_sterge
		LOCAL lcSql, llSucces, lnIdNotificare
		lnIdNotificare = NVL(cNotificari.id_notificare, 0)
		IF !EMPTY(m.lnIdNotificare)
			lcSql = [update notificari set sters = 1, dataoras = sysdate, id_utils = ?gnIdUtil where id_notificare = ] + ALLTRIM(STR(m.lnIdNotificare))
			llSucces = goExecutor.oExecuta(m.lcSql)
			IF m.llSucces
				SELECT cNotificari
				DELETE
				THISFORM.griNotificari.SETFOCUS()
				THISFORM.REFRESH
			ENDIF
		ENDIF
	ENDPROC

	PROCEDURE Init
		Lparameters tnIdNotificare, tcAliasParteneri
		
		this.nIdNotificare = IIF(!EMPTY(m.tnIdNotificare), m.tnIdNotificare,0)
		this.cAliasParteneri = IIF(!EMPTY(m.tcAliasParteneri), m.tcAliasParteneri, '')
		IF !EMPTY(m.tnIdNotificare)
			SELECT cNotificari
			LOCATE FOR id_notificare = m.tnIdNotificare
			IF !FOUND()
				GO TOP 
			ENDIF 
		ENDIF 
		
		Thisform.gridextra1.setup()
		
	ENDPROC

	PROCEDURE update_ireg
	ENDPROC

	PROCEDURE grdNotificari.AfterRowColChange
		LPARAMETERS nColIndex
		IF INLIST(this.RowColChange,1,3)
			thisform.text.Refresh()
			thisform.txtTitlu.Refresh()
			thisform.spnOrdine.Refresh()
		ENDIF 	
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_part_cont 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="But_listare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_grid_search1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_grid_order1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid1.Column3.Check1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Grid_parteneri.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtpartener" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_acont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkToateConturile" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: update_ireg
		*p: cordinegrid1
		*p: nid_part
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 3
		cbuton1 = 
		cbuton2 = but_listare1;but_excel1
		cordinegrid1 = 
		DoCreate = .T.
		Height = 503
		Name = "frm_part_cont"
		nid_part = -1
		Width = 664
		WindowState = 2
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 670
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 602
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 70
		Lb_titlu_alb_b121.Caption = "INVENTARUL PATRIMONIULUI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.FontSize = 11
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 634
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_txtpartener' AS _textbox WITH ;
		Anchor = 2, ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 15, ;
		Name = "_txtpartener", ;
		Top = 35, ;
		Width = 307
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		Anchor = 2, ;
		Left = 324, ;
		Name = "But_cautare1", ;
		Top = 31
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 9, ;
		caction = do_excel, ;
		Comment = "*:OnResize=RT", ;
		Height = 27, ;
		Left = 571, ;
		Name = "But_excel1", ;
		TabIndex = 42, ;
		Top = 1, ;
		Visible = .T., ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare2' AS but_listare WITH ;
		Anchor = 9, ;
		caction = do_listare, ;
		Left = 604, ;
		Name = "But_listare2", ;
		ToolTipText = "Listare(CTRL+P)", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'chkToateConturile' AS checkbox WITH ;
		Alignment = 0, ;
		Anchor = 9, ;
		AutoSize = .F., ;
		BackStyle = 0, ;
		Caption = "Toate conturile", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 551, ;
		Name = "chkToateConturile", ;
		ToolTipText = "Arata toate conturile sau doar pe cele selectate", ;
		Top = 52, ;
		Value = .F., ;
		Width = 104
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Ck_acont' AS checkbox WITH ;
		Alignment = 0, ;
		Anchor = 9, ;
		AutoSize = .F., ;
		BackStyle = 0, ;
		Caption = "Analitic", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 533, ;
		Name = "Ck_acont", ;
		Top = 34, ;
		Value = 1, ;
		Width = 62
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Ck_cont' AS checkbox WITH ;
		Alignment = 0, ;
		Anchor = 9, ;
		BackStyle = 0, ;
		Caption = "Cont", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 485, ;
		Name = "Ck_cont", ;
		Top = 34, ;
		Value = 1, ;
		Width = 43
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Ct_grid_order1' AS ct_grid_order WITH ;
		Height = 210, ;
		Left = 540, ;
		Name = "Ct_grid_order1", ;
		Top = 456, ;
		Visible = .F., ;
		Width = 354, ;
		_GRID1.Height = 141, ;
		_GRID1.Left = 6, ;
		_GRID1.Name = "_GRID1", ;
		_GRID1.Top = 62, ;
		_GRID1.Width = 343, ;
		Titlu.Caption = "PARTENERI / CONTURI", ;
		Titlu.Name = "Titlu", ;
		Cb_tx_cautare1.Criteriu.Name = "Criteriu", ;
		Cb_tx_cautare1.Name = "Cb_tx_cautare1", ;
		Cb_tx_cautare1.Text.Name = "Text"
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_grid_search1' AS ct_grid_search WITH ;
		Anchor = 15, ;
		Height = 256, ;
		Left = 8, ;
		Name = "Ct_grid_search1", ;
		Top = 247, ;
		Width = 656, ;
		_GRID1.Height = 214, ;
		_GRID1.HighlightStyle = 2, ;
		_GRID1.Left = 6, ;
		_GRID1.Name = "_GRID1", ;
		_GRID1.RecordMark = .T., ;
		_GRID1.Top = 38, ;
		_GRID1.Width = 646, ;
		Titlu.Caption = "ÎNREGISTRÃRI", ;
		Titlu.Left = 10, ;
		Titlu.Name = "Titlu", ;
		Titlu.Top = 11, ;
		Cb_tx_cautare1.Criteriu.Name = "Criteriu", ;
		Cb_tx_cautare1.Left = 350, ;
		Cb_tx_cautare1.Name = "Cb_tx_cautare1", ;
		Cb_tx_cautare1.Text.Name = "Text", ;
		Cb_tx_cautare1.Top = 7, ;
		Cb_tx_cautare1.Visible = .F.
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'Grid1' AS grid WITH ;
		Anchor = 9, ;
		ColumnCount = 3, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		GridLines = 0, ;
		HeaderHeight = 19, ;
		Height = 175, ;
		Left = 360, ;
		Name = "Grid1", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordMark = .F., ;
		RowHeight = 19, ;
		ScrollBars = 2, ;
		Top = 72, ;
		Width = 300, ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 58, ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 164, ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .F., ;
		Column3.Sparse = .F., ;
		Column3.Width = 34
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'Grid1.Column1.Header1' AS header WITH ;
		Caption = "Cont", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'Grid1.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Grid1.Column2.Header1' AS header WITH ;
		Caption = "Denumire", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'Grid1.Column2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Grid1.Column3.Check1' AS checkbox WITH ;
		Alignment = 0, ;
		Caption = "", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 16, ;
		Name = "Check1", ;
		ReadOnly = .F., ;
		Top = 31, ;
		Width = 60
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Grid1.Column3.Header1' AS header WITH ;
		Caption = "Ales", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'Grid_parteneri' AS grid WITH ;
		Anchor = 11, ;
		ColumnCount = 1, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		Height = 176, ;
		HighlightStyle = 2, ;
		Left = 14, ;
		Name = "Grid_parteneri", ;
		ReadOnly = .T., ;
		RecordMark = .T., ;
		RowHeight = 19, ;
		Top = 72, ;
		Width = 334, ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T.
		*< END OBJECT: BaseClass="grid" />

	ADD OBJECT 'Grid_parteneri.Column1.Header1' AS header WITH ;
		Caption = "Header1", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'Grid_parteneri.Column1.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Listare grupatã dupã :", ;
		FontCharSet = 238, ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 360, ;
		Name = "Label1", ;
		Top = 33, ;
		Width = 128
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Selectati conturile pentru listare", ;
		FontCharSet = 238, ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 360, ;
		Name = "Label3", ;
		Top = 52, ;
		Width = 185
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE do_cauta
		pcselect = [select id_part,denumire,cod_fiscal from nom_parteneri b] 
		pcFiltruOriginal = [id_part in (select distinct id_part from balanta_parteneri where an = ?gnAn and luna = ?gnLuna] + ;
			gcCondSucursala + [)]
		pcfiltru = [1=2] 
		pcschema = []
		pcorder = [NUME]
		pccoloane = [denumire,cod_fiscal]
		pcTitlu = [Selectati partenerul]
		lcNumeProc = []
		pcTitluColoane = [Nume,Cod fiscal]
		llToateIreg = .T.
		locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,lcNumeProc,llToateIreg, pcFiltruOriginal) && 11.07.2007
		IF gnButon = 2
			lcFiltru = [1=1]
		ELSE 
			IF EMPTY(locauta.id_part)
				locauta.id_part = -1
				lcFiltru = [1=1]	
			ELSE 
				lcFiltru = [id_part = ] + ALLTRIM(STR(locauta.id_part))	
			ENDIF 
			
		ENDIF 
		lcSel = this.grid_parteneri.RecordSource 
		SELECT (lcSel)
		SET FILTER TO &lcFiltru
		this.grid_parteneri.SetFocus 
		
	ENDPROC

	PROCEDURE do_excel
		This.do_listare(.T.)
	ENDPROC

	PROCEDURE do_listare
		Lparameters tlXls
		*!* 08.12.2010
		*!* marius.muut
		*!* se poate lista o notificare cu sold 0 (fara facturi)
		*!* export in XLS
		
		Local llVal, lcSelect
		Local lcCont, lcFileXLS, lnTipRaport
		*:Global pcOrder, pnOrder
		lcSelect = Select()
		llVal = .T.
		
		This.AlwaysOnTop = .F.
		pcOrder = [nume]
		pnOrder = 0
		If This.ck_cont.Value = 1
			pcOrder = pcOrder + [,cont]
			pnOrder = pnOrder + 1
		Endif
		If This.ck_acont.Value = 1
			pcOrder = pcOrder + [,acont]
			pnOrder = pnOrder + 2
		Endif
		
		Create Cursor crsConturiTemp (Cont c(4))
		
		Select (This.grid1.RecordSource)
		Scan For ales = 1
			lcCont = Cont
			Insert Into crsConturiTemp (Cont) Values (lcCont)
		Endscan
		
		Select * From (This.ct_grid_search1.cnumecursor) ;
			Where Cont In (Select Cont From crsConturiTemp) ;
			Into Cursor crs_list ;
			Order By &pcOrder ;
			Readwrite
		
		*!* 08.12.2010
		If _Tally = 0
			Select crs_list
			Append Blank
		Endif
		*!* 08.12.2010 ^
		Use In crsConturiTemp
		
		If This.ck_cont.Value = 0
			Update crs_list Set Cont = ''
		Endif
		
		*!* 08.12.2010
		If tlXls
			lcFileXLS = Putfile("Salvare raport", "inventar_patrimoniu.xls", "xls")
			If !Empty(m.lcFileXLS)
				Select crs_list
				Copy To (m.lcFileXLS) Type Xl5
				open_default_app(m.lcFileXLS)
			Endif
		Else
			lnTipRaport = xmenu('\<Listare standard;Listare \<inaintare si anexa')
			If !Empty(m.lnTipRaport)
				*THISFORM.LockScreen = .T.
				SAVE_GRID_TAG(This.grid1)
				SAVE_GRID_TAG(This.ct_grid_order1._grid1)
		
				Select crs_list
				Do list_inventar_p With 'crs_list', pnOrder, llVal, m.lnTipRaport In orapoarte.prg
		
				RESTORE_GRID_TAG(This.grid1)
				RESTORE_GRID_TAG(This.ct_grid_order1._grid1)
				*THISFORM.LockScreen = .F.	
			Endif && !EMPTY(m.lnTipRaport)
		Endif
		*!* 08.12.2010 ^
		Select (lcSelect)
		This.AlwaysOnTop = .T.
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.update_ireg(.T.)
	ENDPROC

	PROCEDURE update_ireg
		Lparameters tlFirstTime
		
		Local lcSelect
		Local lcCursor, llToateConturile
		
		Private pcSchema, pnAn, pnLuna, pnId_Part, pnCont, pnAcont
		pcSchema = gcS
		pnAn = gnAn
		pnLuna = gnLuna
		
		
		If tlFirstTime
			pnId_Part = -1
		Else
			pnId_Part = Thisform.nid_part
		Endif
		
		
		If This.ck_cont.Value = 1
			pnCont = 1
		Else
			pnCont = 0
		Endif
		
		If This.ck_acont.Value = 1
			pnAcont = 1
		Else
			pnAcont = 0
		Endif
		
		*!* MODIFICAT 21.12.2005
		*!* MARIUS.MUTU
		*!* am pus din nou selectul aici pentru ca dadea eroare C00005 daca avea parametrii prin ?
		
		*!*	lcSelect = [select pack_situatii_financiare.inventar_patrimoniu_ireg('] + ;
		*!*		pcSchema + [', ] + TRANSFORM(pnAn) + [, ] + TRANSFORM(pnLuna) + [, ] + TRANSFORM(pnId_Part) + [, ] + ;
		*!*		TRANSFORM(pnCont) + [, ] + TRANSFORM(pnAcont) + [) from dual]
		
		*!*	STRTOFILE(lcSelect,'c:\select.txt')
		If tlFirstTime
			*!*		thisform.ct_grid_search1.cSelect = lcSelect
			Thisform.ct_GRID_SEARCH1.initializare(.T.)
			Thisform.ct_GRID_SEARCH1._GRID1.AutoFit()
		
			llToateConturile = Thisform.chkToateConturile.Value && arata toate conturile sau doar pe cele selectate
			lcCursor = Thisform.grid1.RecordSource
			If Used(m.lcCursor)
				If m.llToateConturile
					Set Filter To In (m.lcCursor)
				Else
					Set Filter To ales = 1 In (m.lcCursor)
				Endif
			Endif
			Thisform.grid1.Refresh()
		Else
			*!*		thisform.ct_grid_search1.ocursor.ca_baza1.cSelect = lcSelect
			Thisform.ct_GRID_SEARCH1.actualizeaza_grid()
		Endif
	ENDPROC

	PROCEDURE chkToateConturile.Valid
		Local lcCursor, llToateConturile
		llToateConturile = Thisform.chkToateConturile.Value && arata toate conturile sau doar pe cele selectate
		lcCursor = Thisform.grid1.RecordSource
		If Used(m.lcCursor)
			If m.llToateConturile
				Set Filter To In (m.lcCursor)
			Else
				Set Filter To ales = 1 In (m.lcCursor)
			Endif
		Endif
		Thisform.grid1.Refresh()
		
		
		
		
	ENDPROC

	PROCEDURE Ck_acont.Valid
		thisform.update_ireg()
		
		
		
		
		
		
		
		
	ENDPROC

	PROCEDURE Ck_acont.When
		IF this.value = 0 AND thisform.ck_cont.Value = 0
			aMESSAGEBOX('Bifati selectia <Listare grupata dupa cont>!',0+48,"Atentie")
			RETURN
		ENDIF 
	ENDPROC

	PROCEDURE Ck_cont.Valid
		IF this.Value = 0
			thisform.ck_acont.Value = 0
			thisform.update_ireg()
		ENDIF 
		
	ENDPROC

	PROCEDURE Ct_grid_search1.corderby_assign
		Lparameters vNewVal
		*To do: Modify this routine for the Assign method
		If Thisform.cOrdineGrid1 = m.vNewVal
			lcASC = Iif(This.Casc = 'ASC','DESC','ASC')
		Else
			lcASC = 'ASC'
		Endif
		Thisform.cOrdineGrid1 = m.vNewVal
		This.Casc = lcASC
		If lcASC = 'ASC'
			This.cPicture = 'Up.bmp'
		Else
			This.cPicture = 'Down.bmp'
		Endif
		If !Inlist(Type(Thisform.cOrdineGrid1),'C','T','D','N')
			This.cb_tx_cautare1.Text.Enabled = .F.
		Else
			This.cb_tx_cautare1.Text.Enabled = .T.
		Endif
		lcOrder = Iif(!Empty(Thisform.cOrdineGrid1),Thisform.cOrdineGrid1 + [ ] + This.Casc, '')
		lcCursor = This._grid1.RecordSource
		This._grid1.salveaza_grid()
		copiaza_structura_cursor(lcCursor,lcCursor+[1])
		Select (lcCursor+[1])
		Append From Dbf(lcCursor)
		Use In (lcCursor)
		Select * From (lcCursor+[1]) Order By &lcOrder Into Cursor (lcCursor)
		This._grid1.incarca_grid()
		
	ENDPROC

	PROCEDURE Grid_parteneri.AfterRowColChange
		LPARAMETERS nColIndex
		
		SELECT crs_parteneri
		SCATTER NAME opart
		thisform.nid_part = opart.id_part
		IF thisform.nid_part = -1
			lcFiltru = []
		ELSE 
			lcFiltru = [ and id_part = ] + ALLTRIM(STR(thisform.nid_part))
		ENDIF 
		lcfiltru = thisform.ct_GRID_SEARCH1.cfiltruoriginal + lcFiltru 
		*!*	thisform.ct_GRID_SEARCH1.actualizeaza_grid(lcFiltru)
		
		thisform.update_ireg()
		
		SELECT crs_parteneri
		lcLista = [-1]
		FOR i = 1 TO FCOUNT('crs_parteneri')
			lcI = Alltrim(Str(i))
			lcField = UPPER(Alltrim(Field(i)))
			lnVal = opart.&lcField
			IF TYPE('lnVal') = 'N'
				IF lnVal = 1 AND UPPER(SUBSTR(lcField,1,1)) = 'C'
					lcLista = lcLista + ',' + SUBSTR(lcField,2)
				ENDIF 
			ENDIF 
		ENDFOR 
		SELECT crs_conturi
		UPDATE crs_conturi SET ales = 1 WHERE INLIST(VAL(cont),&lcLista)
		UPDATE crs_conturi SET ales = 0 WHERE !INLIST(VAL(cont),&lcLista)
		*!*	REPLACE ALL ales WITH 1 FOR INLIST(VAL(cont),&lcLista)
		*!*	REPLACE ALL ales WITH 0 FOR !INLIST(VAL(cont),&lcLista)
		LOCATE 
		thisform.grid1.Refresh 
		SELECT crs_parteneri
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_balana 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="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label7" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cktotal4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ckanalitic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cktotal2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cktotal1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cktotal3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtcont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label10" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Txtcont2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ckregjurnal_redus" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboRaport" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: afisactual		&& actualizeaza filtrarea
		*p: calias
		*p: cfiltru
		*p: raport
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 2
		cfiltru = <fb2p_value>&#13;</fb2p_value>
		DoCreate = .T.
		Height = 331
		Name = "frm_rap_balana"
		raport = ""
		Width = 360
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 450
		_shape1.ZOrderSet = 3
		_shape2.Height = 29
		_shape2.Left = 300
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 60
		_shape2.ZOrderSet = 4
		Lb_titlu_alb_b121.Caption = "Rapoarte bazate pe balanta"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.FontName = "Arial"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Left = 6
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 14
		Lb_titlu_alb_b121.Top = 8
		Lb_titlu_alb_b121.ZOrderSet = 5
		BUT_TERMIN1.Left = 330
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 13
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

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

	ADD OBJECT 'cboRaport' AS combobox WITH ;
		BoundTo = .T., ;
		ColumnCount = 1, ;
		Comment = "*:OnResize=RT", ;
		Height = 24, ;
		Left = 119, ;
		Name = "cboRaport", ;
		RowSource = "4 egalitati 14-6-30 (A4),4 egalitati 14-6-30/A (A4),4 egalitati special (A4),5 egalitati 14-6-30/a (A3),6 egalitati 14-6-30/b (A3)", ;
		RowSourceType = 1, ;
		Style = 2, ;
		Top = 261, ;
		Width = 200
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Ck_cont' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		camp_nume = cont, ;
		Caption = "Selectie cont", ;
		Comment = "*:OnResize=ST", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Left = 180, ;
		Name = "Ck_cont", ;
		TabIndex = 4, ;
		Top = 107, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'ckanalitic' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Conturi analitice", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 37, ;
		Name = "ckanalitic", ;
		TabIndex = 6, ;
		Top = 200, ;
		Value = 0, ;
		Width = 92, ;
		ZOrderSet = 8
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'ckregjurnal_redus' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Registrul jurnal redus", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 37, ;
		Name = "ckregjurnal_redus", ;
		TabIndex = 6, ;
		Top = 291, ;
		Value = 0, ;
		Width = 118, ;
		ZOrderSet = 8
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cktotal1' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Total clase (gr.1)", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 180, ;
		Name = "cktotal1", ;
		TabIndex = 7, ;
		Top = 178, ;
		Value = 0, ;
		Width = 98, ;
		ZOrderSet = 11
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cktotal2' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Total grupe (gr.2)", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 180, ;
		Name = "cktotal2", ;
		TabIndex = 8, ;
		Top = 197, ;
		Value = 0, ;
		Width = 102, ;
		ZOrderSet = 10
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cktotal3' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Total conturi sintetice (gr.3)", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 180, ;
		Name = "cktotal3", ;
		TabIndex = 9, ;
		Top = 217, ;
		Value = 0, ;
		Width = 144, ;
		ZOrderSet = 12
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cktotal4' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Conturi sintetice", ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 37, ;
		Name = "cktotal4", ;
		TabIndex = 5, ;
		Top = 178, ;
		Value = 0, ;
		Width = 91, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Ct1' AS ct WITH ;
		Height = 23, ;
		Left = 98, ;
		Name = "Ct1", ;
		SpecialEffect = 0, ;
		TabIndex = 3, ;
		Top = 128, ;
		Width = 54, ;
		ZOrderSet = 18, ;
		Shape1.Name = "Shape1", ;
		Text1.Height = 21, ;
		Text1.Left = 1, ;
		Text1.Name = "Text1", ;
		Text1.Top = 1, ;
		Text1.Width = 13, ;
		Text2.Left = 14, ;
		Text2.Name = "Text2", ;
		Text2.Top = 1, ;
		Text3.Left = 26, ;
		Text3.Name = "Text3", ;
		Text3.Top = 1, ;
		Text4.Height = 21, ;
		Text4.Left = 39, ;
		Text4.Name = "Text4", ;
		Text4.Top = 1, ;
		Text4.Width = 14, ;
		Line1.Left = 14, ;
		Line1.Name = "Line1", ;
		Line1.Top = -9, ;
		Line2.Left = 26, ;
		Line2.Name = "Line2", ;
		Line2.Top = -9, ;
		Line3.Left = 39, ;
		Line3.Name = "Line3", ;
		Line3.Top = -9
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		BackColor = 255,255,255, ;
		BackStyle = 1, ;
		Caption = "Cont", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 36, ;
		Name = "Label1", ;
		TabIndex = 20, ;
		Top = 81, ;
		Width = 28, ;
		ZOrderSet = 23
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label10' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Raport balanta", ;
		Comment = "*:OnResize=RT", ;
		FontBold = .F., ;
		FontSize = 8, ;
		Height = 16, ;
		Left = 37, ;
		Name = "Label10", ;
		TabIndex = 13, ;
		Top = 266, ;
		Width = 72, ;
		ZOrderSet = 14
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "De la", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 36, ;
		Name = "Label2", ;
		TabIndex = 15, ;
		Top = 106, ;
		Width = 27, ;
		ZOrderSet = 20
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Analitic", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 36, ;
		Name = "Label3", ;
		TabIndex = 19, ;
		Top = 132, ;
		Width = 34, ;
		ZOrderSet = 21
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label4' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "la", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 102, ;
		Name = "Label4", ;
		TabIndex = 18, ;
		Top = 106, ;
		Width = 10, ;
		ZOrderSet = 22
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label7' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada de referinta", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 35, ;
		Name = "Label7", ;
		TabIndex = 17, ;
		Top = 33, ;
		Width = 128, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label8' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Anul:", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 121, ;
		Name = "Label8", ;
		TabIndex = 17, ;
		Top = 60, ;
		Width = 26, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label9' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Luna:", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 35, ;
		Name = "Label9", ;
		TabIndex = 17, ;
		Top = 60, ;
		Width = 29, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		BackStyle = 0, ;
		BorderColor = 128,128,128, ;
		Height = 68, ;
		Left = 24, ;
		Name = "Shape1", ;
		Top = 90, ;
		Width = 313, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		BorderColor = 128,128,128, ;
		Height = 73, ;
		Left = 24, ;
		Name = "Shape2", ;
		Top = 168, ;
		Width = 313, ;
		ZOrderSet = 2
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackStyle = 0, ;
		BorderColor = 128,128,128, ;
		Height = 65, ;
		Left = 24, ;
		Name = "Shape3", ;
		Top = 251, ;
		Width = 313, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Text1' AS textbox WITH ;
		BorderColor = 128,128,128, ;
		ControlSource = "gnluna", ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 19, ;
		Left = 65, ;
		Name = "Text1", ;
		SpecialEffect = 1, ;
		Top = 56, ;
		Width = 38
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Text2' AS textbox WITH ;
		BorderColor = 128,128,128, ;
		ControlSource = "gnan", ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 19, ;
		Left = 148, ;
		Name = "Text2", ;
		SpecialEffect = 1, ;
		Top = 56, ;
		Width = 38
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtcont' AS textbox WITH ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		Height = 23, ;
		Left = 61, ;
		Name = "txtcont", ;
		SpecialEffect = 1, ;
		TabIndex = 1, ;
		Top = 102, ;
		Width = 37, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Txtcont2' AS textbox WITH ;
		Comment = "*:OnResize=LT", ;
		ControlSource = "", ;
		Format = "k", ;
		Height = 23, ;
		Left = 111, ;
		Name = "Txtcont2", ;
		SpecialEffect = 1, ;
		TabIndex = 2, ;
		Top = 102, ;
		Width = 37, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Activate
		DO CASE
			CASE UPPER(alltrim(THIS.raport)) = UPPER("Balanta")
				THIS.cktotal4.VALUE = 1
			CASE UPPER(ALLTRIM(THIS.raport)) = UPPER("Registrul jurnal redus")
			    THIS.cktotal4.VALUE = 1
				THIS.opt2.VALUE = 3
		ENDCASE
		
	ENDPROC

	PROCEDURE afisactual		&& actualizeaza filtrarea
		Private lcbal,lcacont, lcFiltre
		lcbal=Thisform.calias
		
		lcFiltre='1=1'
		
		lccont1=Alltrim(This.txtcont.Value)
		lccont2=Alltrim(This.txtcont2.Value)
		
		If Empty(lccont2)
			lccont2 = lccont1
		Endif
		
		lcacont1=Alltrim(This.ct1.text1.Value)
		lcacont2=Alltrim(This.ct1.text2.Value)
		lcacont3=Alltrim(This.ct1.text3.Value)
		lcacont4=Alltrim(This.ct1.text4.Value)
		
		Do Case
		Case Len(lccont1)=1
			lcFiltre = lcFiltre + [ and VAL(LEFT(G1,1))>=] + lcCont1
		Case Len(lccont1)=2
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G2),2,'0'))>=] + lcCont1
		Case Len(lccont1)=3
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G3),3,'0'))>=] + lcCont1
		Case Len(lccont1)=4
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G4),4,'0'))>=] + lcCont1
		Endcase
		
		Do Case
		Case Len(lccont2)=1
			lcFiltre = lcFiltre + [ and VAL(LEFT(G1,1))<=] + lcCont2
		Case Len(lccont2)=2
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G2),2,'0'))<=] + lcCont2
		Case Len(lccont2)=3
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G3),3,'0'))<=] + lcCont2
		Case Len(lccont2)=4
			lcFiltre = lcFiltre + [ and VAL(PADR(ALLTRIM(G4),4,'0'))<=] + lcCont2
		Endcase
		
		llTotal1=Iif(This.cktotal1.Value=1,.T.,.F.)
		llTotal2=Iif(This.cktotal2.Value=1,.T.,.F.)
		llTotal3=Iif(This.cktotal3.Value=1,.T.,.F.)
		llTotal4=Iif(This.cktotal4.Value=1,.T.,.F.)
		llAnalitic=Iif(This.ckanalitic.Value=1,.T.,.F.)
		
		lclista=[]
		If llTotal1
			lclista=lclista+[,1]
		Endif
		If llTotal2
			lclista=lclista+[,2]
		Endif
		If llTotal3
			lclista=lclista+[,3]
		Endif
		If llTotal4
			lclista=lclista+[,] + Iif(glEMama,[6],[4])
		Endif
		If llAnalitic
			lclista=lclista+[,] + Iif(glEMama,[7],[5])
		Endif
		
		
		If !Empty(lclista)
			If Left(lclista,1)=","
				lclista=Substr(lclista,2)
			Endif
			lcFiltre=lcFiltre+[ AND INLIST(BNIVEL,]+lclista+[)]
		Else
			lcFiltre=lcFiltre+[ AND ] + Iif(glEMama,[!InList(bnivel,4,5)],[.F.])
		Endif
		
		lccond2=[]
		
		If !Empty(lcacont1)
			lccond2= lccond2 + [ and SUBSTR(acont,1,1)="]+lcacont1+["]
		Endif
		If !Empty(lcacont2)
			lccond2= lccond2 + [ and SUBSTR(acont,2,1)="]+lcacont2+["]
		Endif
		If !Empty(lcacont3)
			lccond2= lccond2 + [ and SUBSTR(acont,3,1)="]+lcacont3+["]
		Endif
		If !Empty(lcacont4)
			lccond2= lccond2 + [ and SUBSTR(acont,4,1)="]+lcacont4+["]
		Endif
		
		lcFiltre= lcFiltre + lccond2
		If thisform.ck_cont.Value = 1
			lcFiltre = lcFiltre + thisform.ck_cont.filtru_vfp
		Endif
		
		RETURN lcFiltre
		
		
		
	ENDPROC

	PROCEDURE do_listare
		Private pcPerioadaRef, pcDataora
		Store '' To pcPerioadaRef, pcDataora
		
		Local lcFiltru, lcOptiuneRaport,lnNivel,lcCursor
		lnNivel = Iif(glEMama,7,5)
		lcFiltru = Thisform.afisactual()
		lcOptiuneRaport = Upper(Alltrim(Thisform.cboRaport.Value))
		
		LNG1=Thisform.cktotal1.Value
		LNG2=Thisform.cktotal3.Value
		LNG3=Thisform.cktotal3.Value
		LNG4=Thisform.cktotal4.Value
		LNG5=Thisform.ckanalitic.Value
		
		LCBAL = Thisform.calias
		Select (LCBAL)
		
		LCPARTIALA = Iif(!Empty(Thisform.TXTcont.Value)," PARTIALA "," ")
		Do Case
		Case LNG5=1
			m.titlu='- ANALITICA'+LCPARTIALA+'-'
			Select (LCBAL)
			Replace All bifa With .F.
		
			Select Distinct Cont,bnivel,bifa From &LCBAL ;
				WHERE bnivel=lnNivel And &lcFiltru ;
				INTO Cursor listbal Readwrite
		
			If _Tally > 0
				Do Form frm_list_balana
		
				Select listbal
				Scan For bifa
					Scatter Name olist
					Select (LCBAL)
					Replace All bifa With .T. For Cont=olist.Cont And bnivel=lnNivel
					Select listbal
				Endscan
				Release olist
		
				Select (LCBAL)
				lcFiltru = lcFiltru + [ and !bifa]
		
			Endif
			If Used('listbal')
				Use In listbal
			Endif
		
		Case LNG4=1 And LNG5=0
			m.titlu='- SINTETICA'+LCPARTIALA+'-'
		Otherwise
			If Empty(LCPARTIALA)
				m.titlu=""
			Else
				m.titlu='-'+LCPARTIALA+'-'
			Endif
		Endcase
		
		&&preluare ora de pe oracle server:
		*!*	STORE 0 to pnsucces
		*!*	pcexec = [select to_char(SYSdate,'dd/mm/yyyy hh:mi:ss AM') as dataora from dual]
		*!*	pcCursor = [dataora_cursor]
		*!*	pnsucces = goExecutor.oExecute(pcexec,pcCursor)
		*!*	IF (pnsucces != 0)
		*!*		SELECT dataora_cursor
		*!*		pcDataora = dataora_cursor.dataora
		*!*		USE IN dataora_cursor
		*!*	ENDIF
		*!*	pcDataOra = get_ora(2)
		
		lcCursor = [crslistarebal]
		Select (LCBAL)
		*!*	SET FILTER TO &lcFiltru
		If Used(lcCursor)
			Use In (lcCursor)
		Endif
		Select * From (LCBAL) Where &lcFiltru order by g5 Into Cursor (lcCursor)
		Select (lcCursor)
		
		*!*	If This.cktotal4.Value = 1
		*!*	&& conturi sintetice
		*!*		Sum precdeb1, preccred1, precdeb,preccred,ruldeb,rulcred,totdeb,totcred,solddeb,soldcred For bnivel = lnNivel - 1 ;
		*!*			to m.sprecdeb1, m.spreccred1, m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		*!*	Else
		*!*	&& conturi analitice
		*!*		Sum precdeb1, preccred1, precdeb,preccred,ruldeb,rulcred,totdeb,totcred,solddeb,soldcred For bnivel = lnNivel ;
		*!*			to m.sprecdeb1, m.spreccred1, m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		*!*	Endif
		
		If This.cktotal4.Value = 1 and ;
			Empty(Alltrim(This.ct1.text1.Value)) and Empty(Alltrim(This.ct1.text2.Value)) ;
			and Empty(Alltrim(This.ct1.text3.Value)) and Empty(Alltrim(This.ct1.text4.Value))
			&&	imi calculeaza totalul de pe sintetice doar daca nu e completat contul analitic
			&&	altfel iau totalul de pe analitice
			lnNivel = lnNivel - 1
		Endif
		
		Sum precdeb1, preccred1, iif(precdeb>=preccred, abs(precdeb-preccred), 0.00), iif(precdeb<preccred, abs(precdeb-preccred),0.00), ;
			precdeb,preccred,ruldeb,rulcred,totdeb,totcred,solddeb,soldcred For bnivel = lnNivel ;
			to m.sprecdeb1, m.spreccred1, m.ssoldideb, m.ssoldicred, m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		***---------------------------------------------------------------------------------------------
		&& Adaugat 03.05.2006 - pt. Balanta in engleza Alfred Knight
		Private pcSold1ian, pcPrec, pcRul, pcTotal, pcSolduri, pcCont, pcDenumire, plBal_alt
		pcSI1 = 'Solduri initiale 1 Ian.'
		pcSI = 'Solduri initiale'
		pcTSP = 'Total sume precedente'
		pcRLC = 'Rulajele lunii curente'
		pcTS = 'Total Sume'
		pcSF = 'Solduri finale'
		pcTR = 'Total rulaje'
		pcCont = "Cont"
		pcDenumire = "Denumire"
		plBal_alt = .F.
		***
		
		lcRaport = ""
		Do Case
		Case lcOptiuneRaport = Upper("4 Egalitati 14-6-30 (A4)")
			lcRaport="rapbal_a4_4_14_6_30" && A4 4 EGALITATI (TSP, RLC ,TS, SF)
		
		Case lcOptiuneRaport = Upper("4 Egalitati 14-6-30/A (A4)")
			lcRaport="rapbal_a4_4_14_6_30_a" && A4 4 EGALITATI (SI, RLC, TS, SF)
		
		Case lcOptiuneRaport = Upper("4 egalitati special (A4)")
			lcRaport="rapbal_a4_4_14_6_30_a1" && A4 4 EGALITATI (SI, TR, TS, SF)
		
		Case lcOptiuneRaport = Upper("5 Egalitati 14-6-30/a (A3)")
			lcRaport="rapbal_a3_5_14_6_30_a" && A3 5 EGALITATI (SI, TSP, RLC, TS, SF)
		
		Case lcOptiuneRaport = Upper("6 Egalitati 14-6-30/b (A3)")
			lcRaport="rapbal_a3_6_14_6_30_b" && A3 6 EGALITATI (SI, TSP,  RLC, TR, TS, SF)
		Endcase
		
		If Thisform.ckregjurnal_redus.Value=1
			lcRaport = "rap_regjurnal_redus" && A4 REGISTRUL JURNAL REDUS
		Endif
		
		pcPerioadaRef = "Luna: "+Alltrim(Str(gnluna)) + " / " + Alltrim(Str(gnan))
		
		This.AlwaysOnTop = .F.
		*!*	Report Format (lcRaport) To Printer Prompt Preview
		goExport.export2frx(lcCursor,lcRaport)
		This.AlwaysOnTop = .T.
		If Used(lcCursor)
			Use In (lcCursor)
		Endif
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		
		THIS.calias="tbalanta"
		PRIVATE lcbal
		lcbal=THISFORM.calias
		
		SELECT(lcbal)
		GO TOP
		
		
		*!*	PUBLIC m.sprecdeb1,m.spreccred1,m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		*!*	STORE 0 TO m.sprecdeb1,m.spreccred1,m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		
		
		
	ENDPROC

	PROCEDURE Release
		PRIVATE lcbal
		lcbal=thisform.calias 
		
		*RELEASE m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
		
		SELECT (LCBAL)
		SET FILTER TO
	ENDPROC

	PROCEDURE cboRaport.Init
		this.Value = '4 egalitati 14-6-30 (A4)'
	ENDPROC

	PROCEDURE ckanalitic.Click
		
		
	ENDPROC

	PROCEDURE ckregjurnal_redus.Click
		
		
	ENDPROC

	PROCEDURE Ct1.Text1.Valid
		thisform.afisactual 
	ENDPROC

	PROCEDURE Ct1.Text2.Valid
		thisform.afisactual 
	ENDPROC

	PROCEDURE Ct1.Text3.Valid
		thisform.afisactual 
	ENDPROC

	PROCEDURE Ct1.Text4.Valid
		thisform.afisactual 
	ENDPROC

	PROCEDURE txtcont.Valid
		thisform.txtcont2.Value = this.Value 
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_jurnal 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="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="optg" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_luna_intre1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_cont" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: ccont
		*p: cfiltru
		*p: cschema
		*p: cselect
		*p: ctabel
		*p: oobj
		*p: raport
	*</DefinedPropArrayMethod>

	*<PropValue>
		ccont = <TOATE>
		cfiltru = 
		cschema = 
		cselect = 
		ctabel = 
		DoCreate = .T.
		Height = 270
		Name = "frm_rap_jurnal"
		oobj = 
		raport = ""
		Width = 400
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 408
		_SHAPE1.ZOrderSet = 1
		_SHAPE2.Height = 29
		_SHAPE2.Left = 342
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Width = 58
		_SHAPE2.ZOrderSet = 2
		LB_TITLU_ALB_B121.Caption = "Rapoarte bazate pe registrul jurnal"
		LB_TITLU_ALB_B121.FontBold = .T.
		LB_TITLU_ALB_B121.FontName = "Arial"
		LB_TITLU_ALB_B121.FontSize = 10
		LB_TITLU_ALB_B121.Left = 6
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		LB_TITLU_ALB_B121.TabIndex = 5
		LB_TITLU_ALB_B121.Top = 8
		LB_TITLU_ALB_B121.ZOrderSet = 3
		BUT_TERMIN1.Left = 369
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 4
		Gridsort1.Left = 9
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 35
	*</PropValue>

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

	ADD OBJECT 'Clb_luna_intre1' AS clb_luna_intre WITH ;
		BorderColor = 128,128,128, ;
		Height = 29, ;
		Left = 12, ;
		Name = "Clb_luna_intre1", ;
		TabIndex = 2, ;
		Top = 41, ;
		Width = 325, ;
		tx_n1.Left = 161, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.TabIndex = 1, ;
		tx_n1.Top = 3, ;
		Lb_simplu1.Caption = "Perioada de referinta", ;
		Lb_simplu1.FontBold = .T., ;
		Lb_simplu1.FontName = "Arial Narrow", ;
		Lb_simplu1.FontSize = 11, ;
		Lb_simplu1.Left = 7, ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.TabIndex = 2, ;
		Lb_simplu1.Top = 4, ;
		tx_n2.Left = 241, ;
		tx_n2.Name = "tx_n2", ;
		tx_n2.TabIndex = 3, ;
		tx_n2.Top = 3
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_cont' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 286, ;
		Name = "Clb_tx_cont", ;
		TabIndex = 1, ;
		ToolTipText = "Pentru modificare faceti dublu click!", ;
		Top = 136, ;
		Visible = .F., ;
		Width = 106, ;
		Text_simplu1.BorderStyle = 1, ;
		Text_simplu1.ControlSource = "Thisform.ccont", ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 43, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Text_simplu1.SpecialEffect = 1, ;
		Text_simplu1.TabIndex = 2, ;
		Text_simplu1.ToolTipText = "Pentru modificare faceti dublu click!", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 59, ;
		Lb_simplu1.Caption = "Cont", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.TabIndex = 1
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Label5' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Afiseaza:", ;
		Comment = "*:OnResize=LT", ;
		FontBold = .F., ;
		FontName = "Arial Narrow", ;
		FontSize = 11, ;
		Height = 22, ;
		Left = 22, ;
		Name = "Label5", ;
		TabIndex = 6, ;
		Top = 91, ;
		Width = 50, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'optg' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 7, ;
		Height = 178, ;
		Left = 76, ;
		Name = "optg", ;
		SpecialEffect = 1, ;
		TabIndex = 1, ;
		Top = 83, ;
		Value = 0, ;
		Width = 250, ;
		ZOrderSet = 6, ;
		Option1.AutoSize = .F., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Registrul jurnal", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 11, ;
		Option1.Height = 22, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Style = 0, ;
		Option1.Top = 5, ;
		Option1.Value = 0, ;
		Option1.Width = 240, ;
		Option2.AutoSize = .F., ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "Reg. jurnal cu evidentiere sume in valuta", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 11, ;
		Option2.Height = 22, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Style = 0, ;
		Option2.Top = 30, ;
		Option2.Value = 0, ;
		Option2.Width = 240, ;
		Option3.AutoSize = .F., ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "Lista notelor debitoare", ;
		Option3.FontName = "Arial Narrow", ;
		Option3.FontSize = 11, ;
		Option3.Height = 22, ;
		Option3.Left = 5, ;
		Option3.Name = "Option3", ;
		Option3.Style = 0, ;
		Option3.Top = 55, ;
		Option3.Width = 240, ;
		Option4.AutoSize = .F., ;
		Option4.BackStyle = 0, ;
		Option4.Caption = "Lista notelor debitoare - cumulat", ;
		Option4.FontName = "Arial Narrow", ;
		Option4.FontSize = 11, ;
		Option4.Height = 22, ;
		Option4.Left = 5, ;
		Option4.Name = "Option4", ;
		Option4.Style = 0, ;
		Option4.Top = 80, ;
		Option4.Width = 240, ;
		Option5.AutoSize = .F., ;
		Option5.BackStyle = 0, ;
		Option5.Caption = "Lista notelor creditoare", ;
		Option5.FontName = "Arial Narrow", ;
		Option5.FontSize = 11, ;
		Option5.Height = 22, ;
		Option5.Left = 5, ;
		Option5.Name = "Option5", ;
		Option5.Style = 0, ;
		Option5.Top = 105, ;
		Option5.Width = 240, ;
		Option6.AutoSize = .T., ;
		Option6.BackStyle = 0, ;
		Option6.Caption = "Lista notelor creditoare - cumulat", ;
		Option6.FontName = "Arial Narrow", ;
		Option6.FontSize = 11, ;
		Option6.Height = 22, ;
		Option6.Left = 5, ;
		Option6.Name = "Option6", ;
		Option6.Top = 128, ;
		Option6.Width = 199, ;
		Option7.AutoSize = .T., ;
		Option7.BackStyle = 0, ;
		Option7.Caption = "Registru jurnal redus", ;
		Option7.FontName = "Arial Narrow", ;
		Option7.FontSize = 11, ;
		Option7.Height = 22, ;
		Option7.Left = 5, ;
		Option7.Name = "Option7", ;
		Option7.Top = 151, ;
		Option7.Width = 132
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		BackStyle = 0, ;
		BorderColor = 128,128,128, ;
		Height = 185, ;
		Left = 12, ;
		Name = "Shape1", ;
		Top = 79, ;
		Width = 384, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE do_executa
		Lparameters tcFiltru, tcOrder
		
		Private poregjur, pcschema, pclcampuri, pcselect, pcFiltru, pcOrder, pcGroupBy
		Local llAfisare, lnValute
		Local lnIdMonedaNationala, loCauta
		Store '' To m.poregjur
		
		If Empty(m.tcFiltru)
			pcFiltru = This.cfiltru
		Else
			pcFiltru = m.tcFiltru
		Endif
		*!*	modificare	v 2.0.125
		*!*	If Empty(tcOrder)
		If Empty(m.tcOrder) And !Inlist(This.optg.Value, 4, 6)
			*!*	modificare	v 2.0.125	^
			pcOrder = [dataact, nract]
		Else
			pcOrder = Alltrim(m.tcOrder)
		Endif
		
		Do Case
			Case Inlist(This.optg.Value, 1, 2)
				pcschema = ['TIP N(1), LUNA N(2),AN N(4),SERIE_ACT C(10),nract N(20),DATAACT D,DATAIREG D,EXPLICATIA C(150),'+] + ;
					['SCD C(4),ASCD C(4),SCC C(4), ASCC C(4),SUMA N(19,gnPa),PERECHED N(14),PERECHEC N(14),'+] + ;
					['NRORD C(30),PARTC C(50),PARTD C(50),FDOC C(30),'+] + ;
					['EXPLICATIA4 C(100),EXPLICATIA5 C(100),id_valuta n(5),suma_val n(16,gnPval),curs n(10,gnPcurs2),nume_val c(10),sucursala c(100), EXPLICATII C(250)']
		
				pclcampuri = [0 AS TIP, LUNA, AN, NVL(SERIE_ACT,'') AS SERIE_ACT, NRACT, DATAACT, DATAIREG, NVL(EXPLICATIA,' '), SCD, ASCD, SCC, ASCC, SUMA, ] + ;
					[PERECHED, PERECHEC, NVL(NRORD,' ') AS NRORD, NVL(PARTC,' ') AS PARTC, NVL(PARTD,' ') AS PARTD, NVL(FDOC,' ') AS FDOC, ] + ;
					[NVL(EXPLICATIA4,' ') AS EXPLICATIA4, NVL(EXPLICATIA5,' ') AS EXPLICATIA5, NVL(id_valuta,0) as ID_VALUTA, suma_val, curs, nume_val, sucursala, LPAD('', 250, ' ') as explicatii ]
		
				pcselect = [select ] + m.pclcampuri + [ from vact]
				pcGroupBy = []
				*!*	modificare	v 2.0.125
			Case Inlist(This.optg.Value, 4, 6)
				pcschema = ['SCD C(4),SCC C(4),SUMA N(19,gnPa), SUCURSALA c(100)']
				pclcampuri = [SCD, SCC, SUM(SUMA) as SUMA, sucursala ]
				pcselect = [select ] + m.pclcampuri + [ from ] + gcS + [.vact_redus]
				pcGroupBy = [scd,scc,sucursala]
				*!*	modificare	v 2.0.125	^
			Otherwise
				pcschema = ['LUNA N(2),AN N(4),SERIE_ACT C(10), nract N(20),DATAACT D, DATAIREG D,SCD C(4),ASCD C(4),SCC C(4), ASCC C(4),SUMA N(19,gnPa), SUCURSALA c(100)']
				pclcampuri = [LUNA, AN,SERIE_ACT, NRACT, DATAACT, DATAIREG, SCD, ASCD, SCC, ASCC, SUMA,sucursala ]
				*!*			pcselect=[select ] + pclcampuri + [ from ] + gcS + [.act ]
				*!*			pcFiltru = pcFiltru + [ and sters = 0 ]
				pcselect = [select ] + m.pclcampuri + [ from ] + gcS + [.vact_redus ]
				pcGroupBy = []
		Endcase
		
		If At([6;], gcAcces) > 0
			pcFiltru = m.pcFiltru + [ AND ID_UTIL=?gnidutil ]
		Endif
		*!*	modificare	v 2.0.125
		If Substr(Thisform.ccont, 1, 1) <> [<]
			pcFiltru = m.pcFiltru + [ AND ] + Iif(Inlist(This.optg.Value, 3, 4), [scd], [scc]) + [ = '] + Alltrim(Thisform.ccont) + [']
		Endif
		*!*	modificare	v 2.0.125	^
		llAfisare = .F.
		gencursor('poregjur', 'regjurnal', m.pcselect, m.pcFiltru, m.pcschema, m.pcOrder, m.llAfisare, m.pcGroupBy, .T.)
		m.poregjur.ca_baza1.afisare()
		
		If Inlist(This.optg.Value, 1, 2) && reg jurnal
			Update regjurnal Set explicatii = Iif(glEMama,Allt(Nvl(sucursala,''))+';','') + ;
				IIF(!Empty(Nvl(partd,'')), Allt(partd) + '; ', '') + ;
				IIF(!Empty(Nvl(partc,'')), Allt(partc) + '; ', '') + ;
				IIF(!Empty(Nvl(explicatia,'')), Allt(explicatia) +'; ', '') + ;
				IIF(!Empty(Nvl(nrord,'')), Allt(nrord)+'; ', '') + ;
				iif(Empty(pereched), Iif(Empty(perechec),"",Allt(Str(perechec))),Allt(Str(pereched)))+';'+ ;
				IIF(!EMPTY(ALLTRIM(NVL(explicatia4,''))), allt(explicatia4) +'; ', '') + ;
				IIF(!EMPTY(ALLTRIM(NVL(explicatia5,''))), allt(explicatia5) + '; ', '') + ;
				IIF(!EMPTY(NVL(nume_val,'')) AND !EMPTY(NVL(curs,0)), allt(nume_val) + '; ', '') + ;
				IIF(!EMPTY(NVL(curs,0)), allt(STR(curs,12,4)) + '; ', '')
		Endif
		
		If This.optg.Value = 2 && reg jurnal cu sume in valuta
			loCauta = GetMonedaNationala()
			lnIdMonedaNationala = m.loCauta.id_valuta
		
			Calculate Cnt() For !Inlist(Nvl(id_valuta, 0), 0,  m.lnIdMonedaNationala) To m.lnValute In regjurnal
		
			If m.lnValute > 0
				* Total pe valute
				Select 1 As tip, nume_val, Sum(suma) As suma, Sum(suma_val) As suma_val From regjurnal Order By 2 Group By nume_val Into Cursor cTotalValuta
				Select regjurnal
				Append From Dbf('cTotalValuta')
				Use In (Select('cTotalValuta'))
			Endif
		Endif
		
		Return 'regjurnal'
		
	ENDPROC

	PROCEDURE do_listare
		PRIVATE  pcPerioadaRef, pcDataora
		STORE '' TO pcPerioadaRef, pcDataora
		
		lcLunaMin =SUBSTR(ALLTRIM(this.clb_luna_intre1.tx_n1.Value),1,2)
		lcAnMin = SUBSTR(ALLTRIM(this.clb_luna_intre1.tx_n1.Value),3)
		
		lcLunaMax = SUBSTR(ALLTRIM(this.clb_luna_intre1.tx_n2.Value),1,2)
		lcAnMax = SUBSTR(ALLTRIM(this.clb_luna_intre1.tx_n2.Value),3)
		
		IF EMPTY(lcLunaMin)
			lcLunaMin = '1'
		ENDIF 
		IF EMPTY(lcAnMin)
			lcAnMin = ALLTRIM(STR(gnAn))
		ENDIF 
		IF EMPTY(lcLunaMax)
			lcLunaMax = ALLTRIM(STR(gnLuna))
		ENDIF 
		IF EMPTY(lcAnMax)
			lcAnMax = ALLTRIM(STR(gnAn))
		ENDIF 
		
		lcFilter = [luna + 12*an between ] + lcLunaMin + [ + 12*] + lcAnMin + [ and ] + lcLunaMax + [ + 12*] + lcAnMax + gcCondSucursala
		lcOrder = [dataact]
		pcPerioada = [Perioada: ] + lcLunaMin  + [/] + lcAnMin + [ - ] + lcLunaMax + [/] + lcAnMax
		
		DO case
			CASE thisform.optg.Value = 1
				pctitlu = [REGISTRUL JURNAL]
				lcRaport = "rap_regjurnal"
				lcOrder = [dataireg, id_act]
				
			CASE thisform.optg.Value = 2
				pctitlu = [REGISTRUL JURNAL]
				lcRaport = "rap_regjurnal_val"
				lcOrder = [dataireg, id_act]
						
			CASE thisform.optg.Value = 3
			    ** ordonez si filtrez inregistrarile
				lcFilter = lcFilter + [ and suma <> 0]
				lcOrder = [scd,dataact,serie_act,nract]
			    lcRaport = "rap_note_debitoare"	 
		*!*	modificare v 2.0.125	       	
			CASE thisform.optg.Value = 4
				lcFilter = lcFilter + [ and suma <> 0]
				lcOrder = [scd,scc]
			    lcRaport = "rap_note_debitoare_cum"	 
		*!*	modificare v 2.0.125	^
			CASE thisform.optg.Value = 5
			    ** ordonez si filtrez inregistrarile
				lcFilter = lcFilter + [ and suma <> 0]
				lcOrder = [scc,dataact,serie_act,nract]
			    lcRaport= "rap_note_creditoare"
		*!*	modificare v 2.0.125	       	
			CASE thisform.optg.Value = 6
				lcFilter = lcFilter + [ and suma <> 0]
				lcOrder = [scc,scd]
			    lcRaport = "rap_note_creditoare_cum"	 
		*!*	modificare v 2.0.125	^
			OTHERWISE
				** Registru jurnal redus
		*!*			DO make_tbalanta
				Do make_tbalanta With .F., Val(lcLunaMin), Val(lcAnMin), Val(lcLunaMin), Val(lcAnMin)
				*SELECT tbalanta
		ENDCASE 
		
		IF thisform.optg.Value = 7
			lcCrs = "tbalanta"
			If glEMama
				lcFilter = " bnivel = 6 "
			ELSE
				lcFilter = " BNIVEL = 4 "
			endif
			SELECT (lcCrs)
			Sum precdeb1, preccred1, iif(precdeb>=preccred, abs(precdeb-preccred), 0.00), iif(precdeb<preccred, abs(precdeb-preccred),0.00),;
				precdeb,preccred,ruldeb,rulcred,totdeb,totcred,solddeb,soldcred For &lcFilter ;
			to m.sprecdeb1, m.spreccred1, m.ssoldideb, m.ssoldicred, m.sprecdeb,m.spreccred,m.sruldeb,m.srulcred,m.stotdeb,m.stotcred,m.ssolddeb,m.ssoldcred
			SET FILTER TO &lcFilter
			lcRaport = "rap_regjurnal_redus"
			pcPerioada = [Luna: ] + lcLunaMin  + [/] + lcAnMin
		ELSE
			lcCrs = this.do_executa(lcFilter, lcOrder)
		ENDIF 
		
		*pcPerioadaRef = "Luna: "+ALLTRIM(STR(gnluna)) + " / " + ALLTRIM(STR(gnan))
		pcPerioadaRef = pcPerioada
		*!*	pcdataora = get_ora(2)
		
		
		*---------------- UN FEL DE DENOMINARE daca data in care am intrat este mai mare decat 7/2005
		IF VAL(lcAnMin)*12 + VAL(lcLunaMin) < gnAnRon*12 + gnLunaRon
			SELECT (lcCrs)
			REPLACE ALL suma WITH  ROUND(suma/10000,gnPc) FOR an*12 + luna < gnAnRon*12 + gnLunaRon
		ENDIF
		*---------------- END UN FEL DE DENOMINARE
		
		*!*	SELECT (lcCrs)
		thisform.AlwaysOnTop = .f.
		*!*	REPORT FORMAT (lcRaport) TO PRINTER PROMPT preview
		goExport.export2frx(lcCrs,lcRaport,, , , , , .T.)
		thisform.AlwaysOnTop = .t.
		
		SET ORDER TO 
		
		SET FILTER TO 
		    
		
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.clb_luna_intre1.tx_n1.Value = PADL(gnLuna, 2, '0') + STR(gnAn,4)
		this.clb_luna_intre1.tx_n2.Value = PADL(gnLuna, 2, '0') + STR(gnAn,4)
		DO CASE
			CASE UPPER(alltrim(THIS.raport)) = UPPER("Registrul jurnal")
				THIS.optg.VALUE = 1
			CASE UPPER(ALLTRIM(THIS.raport)) = UPPER("Lista notelor debitoare")
			    THIS.optg.VALUE = 3
			CASE UPPER(ALLTRIM(THIS.raport)) = UPPER("Lista notelor creditoare")
			    THIS.optg.VALUE = 4
		ENDCASE
	ENDPROC

	PROCEDURE Clb_tx_cont.Text_simplu1.DblClick
		oCont = caut_cont(,,.T.,.T.)
		Thisform.ccont = Iif(!Empty(oCont.Cont),Iif(Substr(oCont.Cont,1,1) = [<],[<TOATE>],oCont.Cont),Thisform.ccont)
		This.Refresh()
	ENDPROC

	PROCEDURE optg.InteractiveChange
		Thisform.ccont = [<TOATE>]
		If Inlist(This.Value,3,4,5,6)
			Thisform.clb_tx_cont.Visible = .T.
			Thisform.clb_tx_cont.Top = Thisform.optg.Top + Thisform.optg.Buttons(This.Value).Top - 2
			Thisform.clb_tx_cont.Refresh()
		Else
			Thisform.clb_tx_cont.Visible = .F.
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_text_inventar AS frm_termin_renunt 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="Ed_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1.txtUltimaZi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1._label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu3._label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu3.edtSumainCont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reface123" UniqueID="" Timestamp="" />

	*<PropValue>
		BorderStyle = 3
		DoCreate = .T.
		Height = 558
		Name = "frm_text_inventar"
		Width = 708
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 709
		_shape2.Height = 29
		_shape2.Left = 581
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 127
		Lb_titlu_alb_b121.Caption = "Text listare"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Left = 676
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
		But_renunt1.Anchor = 8
		But_renunt1.Left = 645
		But_renunt1.Name = "But_renunt1"
		But_renunt1.Top = 1
	*</PropValue>

	ADD OBJECT 'But_reface123' AS but_reface WITH ;
		Anchor = 8, ;
		caction = do_reface, ;
		Left = 583, ;
		Name = "But_reface123", ;
		ToolTipText = "Refacere text original", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Anchor = 8, ;
		Left = 614, ;
		Name = "But_salveaza1", ;
		ToolTipText = "Salvare modificari text", ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ed_tx_simplu1' AS ed_tx_simplu WITH ;
		Anchor = 10, ;
		BackStyle = 1, ;
		Height = 157, ;
		Left = 12, ;
		Name = "Ed_tx_simplu1", ;
		Top = 59, ;
		Width = 684, ;
		_edbase1.Anchor = 10, ;
		_edbase1.ControlSource = "m.pcMesaj1", ;
		_edbase1.Height = 90, ;
		_edbase1.Left = 8, ;
		_edbase1.Name = "_edbase1", ;
		_edbase1.Top = 25, ;
		_edbase1.Width = 668, ;
		_lbbase1.Caption = "Antet", ;
		_lbbase1.Name = "_lbbase1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ed_tx_simplu1._label1' AS _label WITH ;
		Caption = "Ultima zi din luna", ;
		Left = 15, ;
		Name = "_label1", ;
		Top = 129
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT 'Ed_tx_simplu1.txtUltimaZi' AS _textbox WITH ;
		ControlSource = "m.pdData", ;
		Format = "K", ;
		Left = 120, ;
		Name = "txtUltimaZi", ;
		Top = 127
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'Ed_tx_simplu2' AS ed_tx_simplu WITH ;
		Anchor = 10, ;
		BackStyle = 1, ;
		Height = 120, ;
		Left = 12, ;
		Name = "Ed_tx_simplu2", ;
		Top = 223, ;
		Width = 684, ;
		_edbase1.Anchor = 10, ;
		_edbase1.ControlSource = "m.pcMesaj2", ;
		_edbase1.Height = 86, ;
		_edbase1.Left = 9, ;
		_edbase1.Name = "_edbase1", ;
		_edbase1.Top = 29, ;
		_edbase1.Width = 667, ;
		_lbbase1.Caption = "Subsol", ;
		_lbbase1.Name = "_lbbase1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ed_tx_simplu3' AS ed_tx_simplu WITH ;
		Anchor = 15, ;
		BackStyle = 1, ;
		Height = 206, ;
		Left = 12, ;
		Name = "Ed_tx_simplu3", ;
		Top = 349, ;
		Width = 684, ;
		_edbase1.Anchor = 15, ;
		_edbase1.ControlSource = "m.pcMesaj3", ;
		_edbase1.Height = 90, ;
		_edbase1.Left = 8, ;
		_edbase1.Name = "_edbase1", ;
		_edbase1.Top = 24, ;
		_edbase1.Width = 667, ;
		_lbbase1.Caption = "Confirmare", ;
		_lbbase1.Name = "_lbbase1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ed_tx_simplu3._label2' AS _label WITH ;
		Anchor = 4, ;
		Caption = "Suma in cont", ;
		Left = 12, ;
		Name = "_label2", ;
		Top = 124
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="label" />

	ADD OBJECT 'Ed_tx_simplu3.edtSumainCont' AS _editbox WITH ;
		Anchor = 14, ;
		ControlSource = "m.pcSumainCont", ;
		Enabled = .F., ;
		Height = 53, ;
		Left = 12, ;
		Name = "edtSumainCont", ;
		Top = 144, ;
		Width = 667
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="editbox" />

	ADD OBJECT 'Lb_simplu1' AS lb_simplu WITH ;
		Caption = "Verificati corectitudinea textului:", ;
		Left = 13, ;
		Name = "Lb_simplu1", ;
		Top = 37
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />
	
	PROCEDURE do_reface
		*!*	lctitlu = [Refacere]
		*!*	lcimagine = [intreb.ico]
		*!*	lctip = [Intrebare]
		*!*	lcmesaj1 = [Doriti sa resetati textul? ]
		*!*	lcmesaj2 = []
		*!*	ofrm_mesaj = CREATEOBJECT([frm_mesaj],lctitlu,lcimagine,lctip,lcmesaj1,lcmesaj2)
		*!*	ofrm_mesaj.show(1)
		*!*	RELEASE ofrm_mesaj
		*!*	IF gnButon=2
		*!*		RETURN 
		*!*	ENDIF 
		If amessagebox("Doriti sa resetati textul?",4+32,"Confirmare refacere")=7
			Return
		Endif
		
		pcNumeProc = 'INVENTAR_PATRIMONIU'
		lcComanda1 = [update ] + gcS + [.mesaje set mesaj = cdefault where procedura = ?pcNumeProc]
		lnSucces1 = goExecutor.oExecute(lcComanda1)
		IF lnSucces1 < 0
			aMESSAGEBOX(goExecutor.cEroare,0+16,'Eroare')
			RETURN	
		ENDIF
		
		IF USED('crs_texte')
			USE IN crs_texte
		ENDIF 
		pcNumeProc = [INVENTAR_PATRIMONIU]
		lcSql = [select id_mesaj,mesaj,numar from ]+ gcs + [.mesaje where procedura = ?pcNumeProc]
		lcCursor = 'crs_texte'
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		IF lnSucces < 0
			aMESSAGEBOX('Select texte' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
			RETURN 
		ENDIF
		SELECT crs_texte
		LOCATE FOR numar = 1
		IF FOUND()
			pcMesaj1 = ALLTRIM(mesaj)
			ldData = GOMONTH(DATE(gnan,gnluna,1),1)-1
			pcMesaj1 = STRTRAN(pcMesaj1,'DD/MM/YYYY',ALLTRIM(DTOC(ldData)))
		ENDIF 
		LOCATE FOR numar = 2
		IF FOUND()
			pcMesaj2 = ALLTRIM(mesaj)
		ENDIF 
		LOCATE FOR numar = 3
		IF FOUND()
			pcMesaj3 = ALLTRIM(mesaj)
		ENDIF 
		
		this.Ed_tx_simplu1._edbase1.value = pcMesaj1 
		this.Ed_tx_simplu2._edbase1.value = pcMesaj2 
		this.Ed_tx_simplu3._edbase1.value = pcMesaj3
		this.Refresh 
		
		*!*	lctitlu = [Refacere]
		*!*	lcimagine = [info_c.ico]
		*!*	lctip = [Informare]
		*!*	lcmesaj1 = [Actualizarea s-a terminat!]
		
		*!*	ofrm_mesaj = CREATEOBJECT([frm_mesaj],lctitlu,lcimagine,lctip,lcmesaj1)
		*!*	ofrm_mesaj.show(1)
		*!*	RELEASE ofrm_mesaj
		amessagebox("Actualizarea s-a terminat!",64,"Info refacere")
	ENDPROC

	PROCEDURE do_salvare
		lcsql=[update ]+gcS + [.mesaje set mesaj=']+Alltrim(This.Ed_tx_simplu1._edbase1.Value)+[' where id_mesaj=]+This.Ed_tx_simplu1.Tag
		lnSucces = goExecutor.oExecute(lcsql,lcCursor)
		
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		lcsql=[update ]+gcS + [.mesaje set mesaj=']+Alltrim(This.Ed_tx_simplu2._edbase1.Value)+[' where id_mesaj=]+This.Ed_tx_simplu2.Tag
		lnSucces = goExecutor.oExecute(lcsql,lcCursor)
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		
		lcsql=[update ]+gcS + [.mesaje set mesaj=']+Alltrim(This.Ed_tx_simplu3._edbase1.Value)+[' where id_mesaj=]+This.Ed_tx_simplu3.Tag
		lnSucces = goExecutor.oExecute(lcsql,lcCursor)
		If lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		
	ENDPROC

ENDDEFINE
