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

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Combo1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_Criteriu" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_logic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_del" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: deleteobj
		*p: classid
		*p: codcriteriu
		*p: criteriu_nr
		*p: idcamp
		*p: idvalue
		*p: keynomenclator
		*p: logic
		*p: negat
		*p: numecriteriu
		*p: tip
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		BorderWidth = 0
		classid = 
		codcriteriu = none
		criteriu_nr = 0
		Height = 20
		idcamp = 
		idvalue = 
		keynomenclator = .F.
		logic = 
		Name = "_ccriteriu"
		negat = .F.
		numecriteriu = 
		TabIndex = 99
		tip = 
		Width = 490
		_memberdata = <VFPData>

		</VFPData>
	*</PropValue>

	ADD OBJECT 'cmd_del' AS label WITH ;
		BackColor = 255,0,0, ;
		BackStyle = 0, ;
		Caption = "X", ;
		FontBold = .F., ;
		FontSize = 12, ;
		FontUnderline = .F., ;
		ForeColor = 0,0,164, ;
		Height = 21, ;
		Left = 479, ;
		MousePointer = 15, ;
		Name = "cmd_del", ;
		StatusBarText = "Sterge elementul din lista de criterii", ;
		TabIndex = 6, ;
		Top = 1, ;
		Width = 12
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Combo1' AS combobox WITH ;
		DisabledBackColor = 171,177,201, ;
		DisabledForeColor = 96,124,159, ;
		DisplayCount = 8, ;
		Height = 20, ;
		Left = 195, ;
		Name = "Combo1", ;
		NumberOfElements = 8, ;
		RowSource = "Incepe cu,este,nu este,contine,nu contine,nu are valori,are valori,alege", ;
		RowSourceType = 1, ;
		SpecialEffect = 1, ;
		Style = 2, ;
		TabIndex = 2, ;
		Top = 0, ;
		Width = 92
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Command1' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = "", ;
		Height = 20, ;
		Left = 449, ;
		Name = "Command1", ;
		SpecialEffect = 1, ;
		Style = 0, ;
		TabIndex = 3, ;
		TabStop = .F., ;
		Top = 0, ;
		Visible = .F., ;
		Width = 25
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'lbl_Criteriu' AS label WITH ;
		BackStyle = 0, ;
		Caption = "lbl_Criteriu", ;
		Height = 15, ;
		Left = 28, ;
		Name = "lbl_Criteriu", ;
		TabIndex = 4, ;
		Top = 5, ;
		Width = 128
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbl_logic' AS label WITH ;
		Alignment = 1, ;
		BackStyle = 0, ;
		Caption = "Label1", ;
		Height = 17, ;
		Left = 2, ;
		Name = "lbl_logic", ;
		TabIndex = 5, ;
		Top = 5, ;
		Width = 24
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Text1' AS textbox WITH ;
		DisabledBackColor = 171,177,201, ;
		DisabledForeColor = 0,0,0, ;
		Format = "!k", ;
		Height = 20, ;
		InputMask = "", ;
		Left = 292, ;
		Name = "Text1", ;
		SpecialEffect = 1, ;
		TabIndex = 1, ;
		Top = 0, ;
		Width = 154
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE deleteobj
		this.Parent.parent.SelectorCriteriu.combo1.setfocus()
		
		CurrentObjectNumber=VAL(ALLTRIM(SUBSTR(this.Name,9)))
		this.Tag="Sters"
		lnDeletedHeight =this.Height + 10
		this.Parent.parent.CurrentHeight=this.Parent.Parent.CurrentHeight - lnDeletedHeight
		this.Height=0
		FOR n=CurrentObjectNumber TO this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(n)
		this.Parent.&ObjectName..top=this.Parent.&ObjectName..top-lnDeletedHeight
		ENDFOR
		lnSpeciale=0
		
		FOR n=1 TO this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(n)
		IF this.Parent.&ObjectName..tag#"GroupOpen" and this.Parent.&ObjectName..tag#"GroupClose"
			IF this.Parent.&ObjectName..codcriteriu#"none" AND this.Parent.&ObjectName..Tag#"Sters"
				lnSpeciale=lnSpeciale+1	
			ENDIF
			
		*!*	FOR n = 1 TO ALEN(this.acriterii,1)
		*!*	lctestText=this.acriterii(n,1)
		*!*	lbExists=.F.
		*!*	FOR x=1 TO this.Parent.nr_criterii
		*!*	ObjectName="Criteriu"+Transform(x)
		*!*		IF this.Parent.&ObjectName..Tag#"GroupOpen" AND this.Parent.&ObjectName..Tag#"GroupClose" AND this.Parent.&ObjectName..Tag#"Sters"
		*!*			IF this.Parent.&ObjectName..numecriteriu=lctestText
		*!*				lbExists=.T.
		*!*			ENDIF
		*!*		ENDIF
		*!*	ENDFOR
		*!*	IF lbExists
		*!*	this.combo1.AddItem("\]"+this.acriterii(n,1),n,1)
		*!*		ELSE
		*!*			this.combo1.AddItem(this.acriterii(n,1),n,1)
		*!*		ENDIF
		*!*		ENDFOR
		
		lbExists=.F.
		FOR lncriterii=1 TO this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+Transform(lncriterii)
			
			IF this.Parent.&ObjectName..Tag#"GroupOpen" AND this.Parent.&ObjectName..Tag#"GroupClose" AND this.Parent.&ObjectName..Tag#"Sters"
				IF this.Parent.&ObjectName..numecriteriu=this.numecriteriu
					lbExists=.T.						
				ENDIF
			ENDIF
		ENDFOR
		
			
			
			
			IF this.tip="E"
				FOR EACH ITEM IN this.parent.parent.CONTROLS
					IF LEFT(LOWER(ITEM.NAME),12) = "lbl_criteriu"
							IF item.caption=this.numecriteriu AND NOT lbExists
								ITEM.forecolor=RGB(0,0,0)
								ITEM.stare=""
								ITEM.mousepointer=15
								item.fontbold=.f.
						ENDIF
					ENDIF 	
				ENDFOR
				
			ENDIF
			
			FOR EACH ITEM IN this.parent.parent.CONTROLS
					IF LEFT(LOWER(ITEM.NAME),12) = "lbl_criteriu"
							IF item.caption=this.numecriteriu AND NOT lbExists
								ITEM.forecolor=RGB(0,0,0)
						ENDIF
					ENDIF 	
				ENDFOR
		ENDIF
		ENDFOR
		IF lnSpeciale>0
		ELSE
		ACOPY(this.Parent.parent.SelectorCriteriu.acriterii,temparray)
		this.Parent.parent.SelectorCriteriu.loadarray(@temparray)
		ENDIF
		
		
		this.Parent.do_refresh
		
	ENDPROC

	PROCEDURE Init
		Lparameters criteriu,logic,optiuni,lcKeyNomenclator,tctip,tnId,tcValoare
		This.Visible= .F.
		
		lcTip = tctip
		If At('|', lcTip) > 0
			lcTip = Left(lcTip, At('|', lcTip) -1)
		Endif
		
		
		This.tip=lcTip
		This.logic=logic
		This.lbl_Logic.Caption=Lower(This.logic)
		This.numecriteriu=criteriu
		This.lbl_Criteriu.Caption=Lower(This.numecriteriu)
		If This.Parent.offset>10
			This.Top=This.Parent.Parent.currentHeight - This.Parent.offset
		Else
			This.Top=This.Parent.Parent.currentHeight
		Endif
		
		If optiuni#"Disabled"
			This.combo1.RowSource=optiuni
		Else
			This.combo1.RowSource=""
			This.combo1.Enabled= .F.
			This.text1.Enabled= .F.
		Endif
		
		This.combo1.ListIndex=1
		*!*	THIS.text1.SETFOCUS
		
		Do Case
		Case lcTip = "D1"
			This.text1.InputMask="99/99999"
		Case lcTip = "D"
			This.text1.Value={}
		*!*			THIS.text1.INPUTMASK="99/99/9999"
		Case lcTip = "N"
			lcEvalInputmask = Iif(At('|', tctip) > 0, Substr(tctip,At('|', tctip)+1),'')
			If !Empty(lcEvalInputmask)
				lcInputMask = Strtran(Evaluate(lcEvalInputmask), ' ', '')
			Else
				lcInputMask = "9999999999999999"
			Endif
			This.text1.Format = "RK"
			This.text1.InputMask = lcInputMask
			This.text1.Value = 0
		Endcase
		
		If lcKeyNomenclator#"none"
			This.KeyNomenclator=lcKeyNomenclator
			This.combo1.AddItem("Lista...")
			This.command1.Visible= .T.
			This.command1.Picture="find1.bmp"
		Else
			This.command1.Visible= .F.
		Endif
		If lcTip="I"
			This.combo1.RowSource=""
			This.combo1.RemoveItem(1)
			This.text1.Enabled= .F.
			This.combo1.Enabled= .F.
			This.command1.Visible= .T.
			This.Refresh()
			This.Parent.Refresh()
		
		*!*	modificare ROAGEST v 2.0.55
			If Isnull(tnId)
		*!*	modificare ROAGEST v 2.0.55	^
		** APEL CAUTA_ALFA
		** ==================================================
				loHash = Thisform.loCol(This.KeyNomenclator)
				loCauta = cauta_alfa_hash(loHash)
				lcVarText = "loCauta." + Alltrim(loHash.getValue("cresultcoloana"))
				lcVarId = "loCauta." + Alltrim(loHash.getValue("cidcoloana"))
		
				If !Isnull(loCauta)
					If !Empty(&lcVarText)
						This.idValue=Alltrim(Transform(Evaluate(lcVarId)))
						This.text1.Value=Alltrim(Transform(Evaluate(lcVarText)))
					Endif
				Endif
		**
		** ==================================================
		*!*	modificare ROAGEST v 2.0.55
			Endif
		*!*	modificare ROAGEST v 2.0.55	^
		Endif
		
		*!*	modificare ROAGEST v 2.0.55
		If !Isnull(tcValoare)
			Do case
			Case lcTip = "D"
				This.text1.Value = Ctod(tcValoare)
			Case lcTip = "N"
				This.text1.Value = val(tcValoare)
			Otherwise
				This.text1.Value = tcValoare
			Endcase
		Endif
		If !Isnull(tnId)
			This.idValue = Alltrim(Str(tnId))
		Endif
		*!*	modificare ROAGEST v 2.0.55	^
		
		This.Parent.Refresh()
		
	ENDPROC

	PROCEDURE cmd_del.Click
		this.Parent.deleteobj()
		
	ENDPROC

	PROCEDURE cmd_del.MouseEnter
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ForeColor=RGB(0,0,255)
		this.FontBold=.T.
		this.FontUnderline=.t.
		
		
		
	ENDPROC

	PROCEDURE cmd_del.MouseLeave
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ForeColor=RGB(46,68,101)
		this.FontBold=.F.
		this.FontUnderline= .F.
		
	ENDPROC

	PROCEDURE Combo1.InteractiveChange
		IF THIS.LIST(THIS.LISTINDEX)="Lista..."
			THIS.PARENT.text1.ENABLED=.F.
			** APEL CAUTA_ALFA
			** ==================================================
			loHash = THISFORM.loCol(THIS.PARENT.keynomenclator)
			loCauta = cauta_alfa_hash(loHash)
		
			lcVarText = "loCauta." + ALLTRIM(loHash.getValue("cresultcoloana"))
			lcVarId = "loCauta." + ALLTRIM(loHash.getValue("cidcoloana"))
		
			IF !ISNULL(loCauta)
				IF !EMPTY(&lcVarText)
					THIS.PARENT.idValue=ALLTRIM(TRANSFORM(EVALUATE(lcVarId)))
					THIS.PARENT.text1.VALUE=ALLTRIM(TRANSFORM(EVALUATE(lcVarText)))
				ELSE
					THIS.PARENT.text1.VALUE=""
					THIS.PARENT.combo1.LISTINDEX=1
				ENDIF
			ENDIF
		ENDIF
		
		IF THIS.LIST(THIS.LISTINDEX)#"Lista..."
			THIS.PARENT.text1.ENABLED=.T.
			THIS.PARENT.idValue=""
		ENDIF
		
		IF THIS.PARENT.codcriteriu#"none"
			ALINES(temparray,ALLTRIM(THIS.PARENT.text1.VALUE),1,',')
			THIS.PARENT.codcriteriu=temparray(THIS.LISTINDEX)
		ENDIF
		
		
		
	ENDPROC

	PROCEDURE Combo1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		LOCAL lcTip, nrCriteriu, nrCriteriuNext, lnNrTotalCriterii,  loCriteriuUrmator, llExistaCriteriuUrmator
		nrCriteriu = VAL(SUBSTR(THIS.PARENT.NAME,9))
		nrCriteriuNext = nrCriteriu+1
		CriteriuNext="Criteriu"+ALLTRIM(STR(nrCriteriuNext))
		lnNrTotalCriterii = THIS.PARENT.PARENT.PARENT.nr_criterii
		loCriteriuUrmator = NULL
		
		
		IF INLIST(nKeyCode, 9, 13) 
			&& CAUT CRITERIUL URMATOR
			llExistaCriteriuUrmator = .F.
			FOR i = nrCriteriuNext TO lnNrTotalCriterii
				lcCriteriuNext = "Criteriu" + ALLTRIM(STR(i))
				IF PEMSTATUS(THIS.PARENT.PARENT, lcCriteriuNext, 5) AND !INLIST(THIS.PARENT.PARENT.&lcCriteriuNext..TAG, "GroupOpen", "GroupClose", "Sters")
					llExistaCriteriuUrmator = .T.
					loCriteriuUrmator = THIS.PARENT.PARENT.&lcCriteriuNext
					EXIT
				ENDIF
			ENDFOR
		
			IF llExistaCriteriuUrmator
				&& SAR PE CRITERIUL URMATOR
				NODEFAULT
				loCriteriuUrmator.text1.SETFOCUS()
			ELSE
				&& NU EXISTA CRITERIUL URMATOR - SAR PE PRIMUL CRITERIU / PE BUTONUL TERMINAT
				NODEFAULT
				THIS.PARENT.PARENT.PARENT.but_termin1.SETFOCUS()
				IF .F.
					FOR i = 1 TO nrCriteriu
						lcCriteriu = "Criteriu" + ALLTRIM(STR(i))
						IF PEMSTATUS(THIS.PARENT.PARENT, lcCriteriu, 5)
							IF !INLIST(THIS.PARENT.PARENT.&lcCriteriu..TAG, "GroupOpen", "GroupClose", "Sters")
								NODEFAULT
								THIS.PARENT.PARENT.&lcCriteriu..text1.SETFOCUS()
								EXIT
							ENDIF
						ENDIF
					ENDFOR
				ENDIF
			ENDIF
		
		ENDIF
		
	ENDPROC

	PROCEDURE Combo1.ProgrammaticChange
		If This.List(This.ListIndex)="Lista..."
			This.Parent.text1.Enabled=.F.
		Endif
		
		*!*	If This.List(This.ListIndex)#"Lista..."
		*!*		This.Parent.text1.Enabled=.T.
		*!*		This.Parent.idValue=""
		*!*	Endif
		
		If This.Parent.codcriteriu#"none"
			Alines(temparray,Alltrim(This.Parent.text1.Value),1,',')
			This.Parent.codcriteriu=temparray(This.ListIndex)
		Endif
		
	ENDPROC

	PROCEDURE Command1.Click
		** APEL CAUTA_ALFA
		** ==================================================
		loHash = Thisform.loCol(This.Parent.keynomenclator)
		loCauta = cauta_alfa_hash(loHash)
		lcVarText = "loCauta." + Alltrim(loHash.getValue("cresultcoloana"))
		lcVarId = "loCauta." + Alltrim(loHash.getValue("cidcoloana"))
		
		If !Isnull(loCauta)
			If !Empty(&lcVarText)
				This.Parent.idValue=Alltrim(Transform(Evaluate(lcVarId)))
				This.Parent.text1.Value=Alltrim(Transform(Evaluate(lcVarText)))
				this.Parent.text1.Enabled=.F.
				this.Parent.combo1.ListIndex=8
			ELSE
				this.Parent.text1.Enabled=.T.
				This.Parent.text1.Value=""
				This.Parent.combo1.ListIndex=1
			Endif
		Endif
		
		
		
		
	ENDPROC

	PROCEDURE Text1.InteractiveChange
		this.Parent.idvalue=""
	ENDPROC

	PROCEDURE Text1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		&& dau enter pe un criteriu, verific daca exista urmatorul criteriu - pun focus pe criteriul urmator
		LOCAL lcTip, nrCriteriu, nrCriteriuNext, lnNrTotalCriterii,  loCriteriuUrmator, llExistaCriteriuUrmator
		nrCriteriu = VAL(SUBSTR(THIS.PARENT.NAME,9))
		nrCriteriuNext = nrCriteriu+1
		CriteriuNext="Criteriu"+ALLTRIM(STR(nrCriteriuNext))
		lnNrTotalCriterii = THIS.PARENT.PARENT.PARENT.nr_criterii
		loCriteriuUrmator = NULL
		
		LOCAL lcTip
		lcTip = THIS.PARENT.tip
		IF AT('|', lcTip) > 0
			lcTip = LEFT(lcTip, AT('|', lcTip) -1)
		ENDIF
		
		IF INLIST(nKeyCode, 9, 13) OR (lcTip = 'D1' AND this.SelStart  = 7) 
			&& CAUT CRITERIUL URMATOR
			llExistaCriteriuUrmator = .F.
			FOR i = nrCriteriuNext TO lnNrTotalCriterii
				lcCriteriuNext = "Criteriu" + ALLTRIM(STR(i))
				IF PEMSTATUS(THIS.PARENT.PARENT, lcCriteriuNext, 5) AND !INLIST(THIS.PARENT.PARENT.&lcCriteriuNext..TAG, "GroupOpen", "GroupClose", "Sters")
					llExistaCriteriuUrmator = .T.
					loCriteriuUrmator = THIS.PARENT.PARENT.&lcCriteriuNext
					EXIT
				ENDIF
			ENDFOR
		
			IF llExistaCriteriuUrmator
				&& SAR PE CRITERIUL URMATOR
				NODEFAULT
				loCriteriuUrmator.text1.SETFOCUS()
			ELSE
				&& NU EXISTA CRITERIUL URMATOR - SAR PE PRIMUL CRITERIU / PE BUTONUL TERMINAT
				NODEFAULT
				THIS.PARENT.PARENT.PARENT.but_termin1.SETFOCUS()
				IF .F.
					FOR i = 1 TO nrCriteriu
						lcCriteriu = "Criteriu" + ALLTRIM(STR(i))
						IF PEMSTATUS(THIS.PARENT.PARENT, lcCriteriu, 5)
							IF !INLIST(THIS.PARENT.PARENT.&lcCriteriu..TAG, "GroupOpen", "GroupClose", "Sters")
								NODEFAULT
								THIS.PARENT.PARENT.&lcCriteriu..text1.SETFOCUS()
								EXIT
							ENDIF
						ENDIF
					ENDFOR
				ENDIF
			ENDIF
		
		ENDIF
		
	ENDPROC

	PROCEDURE Text1.Valid
		LOCAL llUltimul, lcCriteriu, i, lcTip
		lcTip = THIS.PARENT.tip
		IF AT('|', lcTip) > 0
			lcTip = LEFT(lcTip, AT('|', lcTip) -1)
		ENDIF
		
		&& validare perioada tipul D1
		IF lcTip = 'D1'
			lcValoare = STRTRAN(THIS.VALUE, '/', '')
			IF !EMPTY(lcValoare)
				lcLuna = SUBSTR(ALLTRIM(lcValoare),1,2)
				lcAn = SUBSTR(ALLTRIM(lcValoare),3)
				IF EMPTY(lcAn) OR LEN(lcAn) < 4
					lcAn = ALLTRIM(STR(YEAR(DATE())))
					THIS.VALUE = PADL(lcLuna, 2, '0')+ '/' + lcAn
				ENDIF
				IF TYPE("DATE(VAL(lcAn),VAL(lcLuna),1)")!="D"
					AMESSAGEBOX("Perioada invalida!",0+16,"Eroare")
					RETURN 0
				ENDIF
			ENDIF
		ENDIF
		
		*!*	&& validare data tipul D
		*!*	IF lcTip = 'D'
		*!*		IF LEN(ALLTRIM(TRANSFORM(this.value))) < 10
		*!*			RETURN 0
		*!*		ENDIF 
		
		*!*		lcValoare = STRTRAN(THIS.VALUE, '/', '')
		*!*		IF !EMPTY(lcValoare)
		*!*			lcZi = SUBSTR(ALLTRIM(lcValoare), 1, 2)
		*!*			lcLuna = SUBSTR(ALLTRIM(lcValoare), 3, 2)
		*!*			lcAn = SUBSTR(ALLTRIM(lcValoare), 5)
		*!*			IF EMPTY(lcAn) OR LEN(lcAn) < 4
		*!*				lcAn = ALLTRIM(STR(YEAR(DATE())))
		*!*				THIS.VALUE = PADL(lcZi, 2, '0') + '/' + PADL(lcLuna, 2, '0')+ '/' + lcAn
		*!*			ENDIF
		*!*			IF TYPE("DATE(VAL(lcAn),VAL(lcLuna),VAL(lcZi))")!="D"
		*!*				AMESSAGEBOX("Data invalida!",0+16,"Eroare")
		*!*				RETURN 0
		*!*			ENDIF
		*!*		ENDIF
		*!*	ENDIF
		
		
		&& daca criteriul urmator este de acelasi tip, ii completez valoarea cu valoarea curenta
		lcNumecriteriu = THIS.PARENT.numecriteriu
		nrCriteriu = VAL(SUBSTR(THIS.PARENT.NAME, 9))
		nrCriteriuNext = nrCriteriu + 1
		CriteriuNext = "Criteriu" + ALLTRIM(STR(nrCriteriuNext))
		
		*!*AMESSAGEBOX('Criteriu' + ALLTRIM(STR(nrCriteriu)) + CHR(13) + GETCALLSTACK())
		
		IF PEMSTATUS(THIS.PARENT.PARENT,CriteriuNext,5)
			loCriteriuNext = THIS.PARENT.PARENT.&CriteriuNext
		
			IF  loCriteriuNext.TAG#"GroupOpen"AND loCriteriuNext.TAG#"GroupClose" AND loCriteriuNext.TAG#"Sters"  ;
					AND loCriteriuNext.numecriteriu = lcNumecriteriu
					IF (lcTip = 'N' ) OR ;	&&	modificare	
						(lcTip <> 'D1' AND EMPTY(loCriteriuNext.text1.VALUE)) OR ;
						(lcTip = 'D1' AND EMPTY(ALLTRIM(STRTRAN(TRANSFORM(loCriteriuNext.text1.VALUE), '/',''))))
						loCriteriuNext.text1.VALUE = THIS.VALUE
				ENDIF
			ENDIF
		ENDIF
		
		
		
		
		
		*!*	&& daca sunt pe ultimul criteriu nesters - de tip D (data) sau D1 (perioada)
		*!*	&& completez primul criteriu, se completeaza automat al doilea criteriu
		*!*	&& si sare focusul pe alt control pentru ca sunt completate toate caracterele din inputmask
		*!*	llUltimul = .T.
		*!*	lnNrTotalCriterii = THIS.PARENT.PARENT.PARENT.nr_criterii
		*!*	FOR i = nrCriteriu+1 TO lnNrTotalCriterii
		*!*		lcCriteriu = "Criteriu" + ALLTRIM(STR(i))
		*!*		IF PEMSTATUS(THIS.PARENT.PARENT, lcCriteriu, 5)
		*!*			IF THIS.PARENT.PARENT.&lcCriteriu..TAG # 'Sters'
		*!*				llUltimul = .F.
		*!*				EXIT
		*!*			ENDIF
		*!*		ENDIF
		*!*	ENDFOR
		*!*	IF llUltimul AND LEFT(lcTip,1) = 'D'
		*!*		*!*		RETURN 0
		*!*	ENDIF
		
	ENDPROC

ENDDEFINE

DEFINE CLASS but_reset_criterii AS buton OF "_cmd_base.vcx" 
 	*< CLASSDATA: Baseclass="commandbutton" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<PropValue>
		caction = do_reset
		Caption = ""
		cpicturedown = reset_jos.bmp
		cpictureup = reset_sus.bmp
		Name = "but_reset_criterii"
		Picture = ..\grafice\reset_sus.bmp
		ToolTipText = "Resetare criterii (CTRL + T)"
		_memberdata = <VFPData>

		</VFPData>
	*</PropValue>
	
	PROCEDURE Click
		If Pemstatus(This.Parent, "DO_RESET", 5)
			This.Parent.do_reset()
		Else
			If Pemstatus(Thisform, "DO_RESET", 5)
				Thisform.do_reset()
			Endif
		Endif
		*!*	_SCREEN.STATUSBAR.TAG = "" && STATUSBAR TOOLTIP
		*!*	_SCREEN.STATUSBAR.ctlMessage = _SCREEN.CAPTION && STATUSBAR MESSAGE
		If Type('this.Parent.but_Start_criterii1') = 'O'
			This.Parent.but_Start_criterii1.refreshstatus()
		Endif
		If Pemstatus(This.Parent,"ocriterii",5)
			This.Parent.ocriterii.Release
			This.Parent.ocriterii=Null
			Removeproperty(This.Parent, "ocriterii")
		Endif
		If Reccount()>0
			_Screen.StatusBar.ctlPanels(2).ctlCaption=Transform(Reccount()) + " inregistrari"
		Else
			_Screen.StatusBar.ctlPanels(2).ctlCaption=""
		Endif
		
		
		
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS but_start_criterii AS buton OF "_cmd_base.vcx" 
 	*< CLASSDATA: Baseclass="commandbutton" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: initform
		*m: loadcriterii
		*m: loadfiltru
		*m: refreshstatus
		*m: resetstatus
		*m: updatedetails
		*p: filtru_pretty_ro_full
		*p: lcautare		&& .T. daca se apeleaza cautarea la iesirea din formularul cu criterii.
		*p: pornit
	*</DefinedPropArrayMethod>

	*<PropValue>
		Caption = ""
		cpicturedown = find_jos.bmp
		cpictureup = find_sus.bmp
		filtru_pretty_ro_full = 
		FontSize = 10
		Height = 27
		lcautare = .T.
		Name = "but_start_criterii"
		Picture = ..\grafice\find_sus.bmp
		pornit = nu
		RightToLeft = .T.
		SpecialEffect = 1
		Style = 0
		ToolTipText = "Cautare (CTRL + Q)"
		Visible = .T.
		Width = 30
		_memberdata = <VFPData>

		</VFPData>
	*</PropValue>
	
	PROCEDURE Click
		This.initform(.T.)
	ENDPROC

	PROCEDURE initform
		Lparameters tlShowForm
		Local Array lacriterii(1,1)
		Local lnButon
		This.loadcriterii(@lacriterii)
		If(This.pornit="nu") or !Pemstatus(This.Parent,"oCriterii",5)
			If !Pemstatus(This.Parent,"oCriterii",5)
				This.Parent.AddProperty("oCriterii")
			Endif
			This.Parent.ocriterii=Null
			This.Parent.ocriterii=Createobject("frm_criterii",@lacriterii)
			This.pornit="da"
		Endif
		
		If tlShowForm
			This.Parent.ocriterii.Show(1)
			lnButon = gnButon
		Else
			lnButon = 2
		Endif
		
		This.updatedetails(lnButon)
	ENDPROC

	PROCEDURE loadcriterii
		*** FORMAT
		*** CAPTION\CAMPURI_BAZA_DATE_SEPARATE_PRIN_VIRGULA|EXPRESIE_COMPLEXA\TIP_CRITERIU\COLOANA_ID_CAUT_ALFA\NOMENCLATOR_COLECTIE_CAUT_ALFA\TOOLTIP + CRLF
		
		* CAPTION
		* LISTA CAMPURI SEPARATE PRIN VIRGULA SAU O EXPRESIE COMPLEXA CU PREFIX |E|
		*	EX: "PARTD,PARTC,EXPLICATIE" SAU "|E|ID_PART IN (SELECT ID_PART FROM TTT WHERE CAMP = <<lcValoare>>)"
		* TIPCRITERIU:
		*	T (TEXT),
		*	N (NUMAR),
		*	D (DATA),
		*	D1 (PERIOADA = AN*12+LUNA),
		*	I (ALEGE NUMAI DIN LISTA),
		*	E (CONDITIE FIXA EX: VALIDATE, CU STOC, EROARE TVA
		*	A (LISTA DE OPTIUNI)
		* COLOANA ID INTOARSA DE CAUT_ALFA
		* CHEIE_COLECTIE_CAUT_ALFA"
		
		*lcStringCriterii="Nume\denumire\T\ID_PART\nom_parteneri" 	+ crlf + ;
		*				  "Nr. act\nract\N\none\"   				+ crlf + ;
		"Data act\dataact\D\none\"				+ crlf + ;
		"Fel document\fel_document\T\none\" 		+ crlf + ;
		"Cod Fiscal\cod_fiscal\T\none\" 			+ crlf + ;
		"Procent TVA\i.proc_tva\N|get_mask(12,gnPA)\none\" + crlf + ;
		"Explicatie D&C\partd,partc\T\|E|ID_PARTD=<<VALOARE>> OR ID_PARTC=<<VALOARE>>\nom_parteneri"+ crlf + ;	
		"In desfasurare\nofiled\A\Contracte in desfasurare,Contracte incetate,Toate#c.incetat = 0,c.incetat=1,1=1\" + crlf + ;
		"EroareTVA\nofiled\E\" 					+ ;
		[ AND ABS(TOTCTVA - (RO19B + RO19T + RO9B + RO9T + ROTI + CESCDD1 + CESCDD2 +] + ;
		[WRSCDD + FODD + FOFDD + WRSCFDD + WRN)) >= 1 AND ] + ;
		[ABS(RO19T) BETWEEN ROUND(0.188*ABS(RO19B),?gnPc) AND ROUND(0.193*ABS(RO19B),?gnPc) AND ] + ;
		[ABS(RO9T) BETWEEN ROUND(0.088*ABS(RO9B),?gnPc) AND ROUND(0.093*ABS(RO9B),?gnPc)\ + crlf
		*DODEFAULT()
		*
		*Sunt doua situatii in care poate fi folosit
		*Caption \denumirea campului \ T sau D sau N sau E (text,data,numeric,exceptie)\comanda exceptie\cheia din colectia de nomenclatoare
		*sau
		*Caption \denumirea campului \ T (sa nu fie E)\numele campului din tabela corespondeta formului care apeleaza\cheia din colectia de nomenclatoare
		
		* daca se doreste ca la intrarea in form sa se puna un filtru:
		*!*	lcfiltru = [In desfasurare;nofiled;1;]
		*!*	llcautare = This.pagefr1.paGE2.ct_contracte1.but_start_criterii1.lcautare
		*!*	This.pagefr1.paGE2.ct_contracte1.but_start_criterii1.lcautare = .F.
		*!*	This.pagefr1.paGE2.ct_contracte1.but_start_criterii1.loadfiltru(lcfiltru)
		*!*	This.pagefr1.paGE2.ct_contracte1.but_start_criterii1.lcautare = llcautare
		
		nroflines=Alines(laCriterii,lcStringCriterii,1,crlf)
		Dimension tacriterii(nroflines,6)
		For N= 1 To nroflines
			For i = 1 To 6
				tacriterii(N,i)=Getwordnum(laCriterii(N),i,"\")
			Endfor
		Endfor
		
	ENDPROC

	PROCEDURE loadfiltru
		Lparameters tcFiltru
		This.initform(.F.)
		This.Parent.ocriterii.do_incarca_filtre(tcFiltru)
		This.updatedetails(1)
		
	ENDPROC

	PROCEDURE refreshstatus
		#Define crlf Chr(13) + Chr(10)
		Local lcText
		lcText = ""
		
		If Pemstatus(This.Parent,"filtru_traducere",5)
			lcText = Iif(Not Empty(This.Parent.filtru_traducere()), This.Parent.filtru_traducere(),"")
		Else
			If Pemstatus(Thisform,"filtru_traducere",5)
				lcText = Iif(Not Empty(Thisform.filtru_traducere()), Thisform.filtru_traducere(),"")
			Endif
		Endif
		
		If PEMSTATUS(this.Parent, 'filtru_pretty_ro', 5) AND !Empty(Alltrim(This.Parent.filtru_pretty_ro))
			lcText = this.parent.filtru_pretty_ro + Iif(!Empty(lcText), " si " + lcText, "")
		Else
			If PEMSTATUS(thisform, 'filtru_pretty_ro', 5) AND !Empty(Alltrim(Thisform.filtru_pretty_ro))
				lcText = Thisform.filtru_pretty_ro + Iif(!Empty(lcText), " si " + lcText, "")
			Endif
		Endif
		
		This.ToolTipText = Iif(!Empty(m.lcText), m.lcText + crlf, "") + "Cautare (CTRL + Q)"
		IF PEMSTATUS(this.Parent, 'filtru_pretty_ro_full', 5)
			this.parent.filtru_pretty_ro_full = m.lcText
		ELSE 	
			IF PEMSTATUS(thisform, 'filtru_pretty_ro_full', 5)
				Thisform.filtru_pretty_ro_full = m.lcText
			ENDIF 
		ENDIF 	
		
		_Screen.StatusBar.Tag = lcText
		
		If !Empty(lcText)
			_Screen.StatusBar.ctlIcon="roastartmic.ico"
			If Len(lcText) < 126
				_Screen.StatusBar.ctlMessage = lcText
			Else
				_Screen.StatusBar.ctlMessage=Substr(lcText,1,122) + " ..."
			Endif
		Else
			_Screen.StatusBar.ctlMessage=_Screen.Caption
		Endif
		
		
		
		
	ENDPROC

	PROCEDURE resetstatus
		IF PEMSTATUS(_SCREEN,"Statusbar",5)
			_SCREEN.STATUSBAR.ctlPanels(2).ctlCaption=""
			_SCREEN.STATUSBAR.ctlMessage = _SCREEN.CAPTION
			_SCREEN.STATUSBAR.TAG = ""
		ENDIF
	ENDPROC

	PROCEDURE updatedetails
		Lparameters tnButon
		If Not Pemstatus(This.Parent,"filtru_pretty",5)
			This.Parent.AddProperty("filtru_pretty")
		Endif
		If Not Pemstatus(This.Parent,"filtru_pretty_ro",5)
			This.Parent.AddProperty("filtru_pretty_ro")
		Endif
		If Not Pemstatus(This.Parent,"filtru_cript",5)
			This.Parent.AddProperty("filtru_cript")
		Endif
		This.Parent.filtru_pretty = This.Parent.ocriterii.filtru
		This.Parent.filtru_pretty_ro = This.Parent.ocriterii.filtruro
		This.Parent.filtru_cript = This.Parent.ocriterii.filtrucript
		
		This.refreshStatus()
		
		
		This.SetFocus
		If Pemstatus(This.Parent,"DO_CAUTA",5) And tnButon = 1 And This.lcautare
			This.Parent.DO_CAUTA()
		
			If Reccount()>0
				_Screen.StatusBar.ctlPanels(2).ctlCaption=Transform(Reccount()) + " inregistrari"
			Else
				_Screen.StatusBar.ctlPanels(2).ctlCaption=""
			Endif
		Else
			If Pemstatus(Thisform,"DO_CAUTA",5) And tnButon = 1 And This.lcautare
				Thisform.DO_CAUTA()
				If Reccount()>0
					_Screen.StatusBar.ctlPanels(2).ctlCaption=Transform(Reccount()) + " inregistrari"
				Else
					_Screen.StatusBar.ctlPanels(2).ctlCaption=""
				Endif
			Endif
		Endif
		
	ENDPROC

ENDDEFINE

DEFINE CLASS cmd_addcriteriu AS label 
 	*< CLASSDATA: Baseclass="label" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: do_initializeaza
		*p: stare
	*</DefinedPropArrayMethod>

	*<PropValue>
		Alignment = 0
		BackStyle = 0
		Caption = "Label1"
		FontCharSet = 238
		FontExtend = .F.
		FontSize = 10
		Height = 16
		MousePointer = 15
		Name = "cmd_addcriteriu"
		stare = 
		Width = 118
	*</PropValue>
	
	PROCEDURE Click
		
		This.do_initializeaza()
	ENDPROC

	PROCEDURE do_initializeaza
		Lparameters tnIndex,tnId,tcValoare
		Local lcTipCriteriu
		If Parameters()=0
			tnIndex = .Null.
			tnId = .Null.
			tcValoare = .Null.
		Endif
		
		lcTipCriteriu = This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),3)
		If At('|', lcTipCriteriu) > 0
			lcTipCriteriu = Left(lcTipCriteriu, At('|', lcTipCriteriu) -1) && tipul criteriului N|GetMask(12,gnPA)
		Endif
		
		If This.stare#"inactiv"
			lctextoptions="incepe cu,este,nu este,contine,nu contine,nu are valori,are valori"
			lcnroptions="egal,diferit,mai mare sau egal,mai mic sau egal,mai mare,mai mic"
			lcdataoptions="egala,diferita,mai mare,mai mica,mai mare sau egala,mai mica sau egala"
			lctext=""
			lcClassId=""
			lnoftimes=1
		
			Do While lnoftimes < 3
				Do Case
					Case Inlist(lcTipCriteriu, "N", "D1")
						lcOptions=lcnroptions
					Case lcTipCriteriu = "T"
						lcOptions=lctextoptions
					Case lcTipCriteriu = "D"
						lcOptions=lcdataoptions
					Case lcTipCriteriu = "E"
						lcOptions="Disabled"
					Case lcTipCriteriu = "A"
						lcOptions=Substr(This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),4),1,At("#",This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),4))-1)
						lctext=Substr(This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),4),At("#",This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),4))+1)
						If(This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),2))#"nofield"
							lcClassId=This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),2)
						Endif
					Otherwise
						lcOptions=lctextoptions
				Endcase
		
				If This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),5)#"" And This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),5)#"none"
					lcKeyNomenclator=This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),5)
					lcIdCamp=This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),4)
				Else
					lcKeyNomenclator="none"
					lcIdCamp=""
				Endif
		
		
				This.Parent.nr_criterii=This.Parent.nr_criterii+1
				NrCriterii=This.Parent.nr_criterii
				ObjectName="Criteriu"+Transform(NrCriterii)
		
				PreviusObjectName="Criteriu"+Transform(NrCriterii-1)
				If(NrCriterii=1 Or This.Parent.Containercriterii1.&PreviusObjectName..Tag="GroupOpen")
					logicCaption=""
				Else
					*** in caz ca sunt sterse primele inregistrari
					lbexinreg=.F.
					For i = 1 To NrCriterii-1
						locurObj="Criteriu"+Transform(i)
						If This.Parent.Containercriterii1.&locurObj..Tag#"Sters"
							lbexinreg=.T.
						Endif
					Endfor
					***
					If lbexinreg=.T.
						logicCaption=This.Parent.SelectorCriteriu.logic
					Else
						logicCaption=""
					Endif
				Endif
		
				With This.Parent
					.Containercriterii1.AddObject("&ObjectName","_ccriteriu",This.Caption,logicCaption,lcOptions,lcKeyNomenclator,This.Parent.SelectorCriteriu.acriteriiuns(Val(Substr(This.Name,13)),3),tnId,tcValoare)
					If lcIdCamp#""
						.Containercriterii1.&ObjectName..idCamp=lcIdCamp
					Endif
					.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..Height+10
					.Containercriterii1.&ObjectName..Left=.currentLeft
					.Containercriterii1.&ObjectName..criteriu_nr=Val(Substr(This.Name,13))
					This.ForeColor=Rgb(15,15,200)
		
					&&			lcTipCriteriu1 = THIS.PARENT.SelectorCriteriu.acriteriiuns(VAL(SUBSTR(THIS.NAME,13)),3)
					*!* setare Mai mare sau egal / Mai mic sau egal in functie de ce e selectat
					If lcTipCriteriu = "D"
						If lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.Value=.Containercriterii1.&ObjectName..combo1.List(5)
						Else
							.Containercriterii1.&ObjectName..combo1.Value=.Containercriterii1.&ObjectName..combo1.List(6)
						Endif
					Endif
					If Inlist(lcTipCriteriu, "N", "D1")
						If lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.Value=.Containercriterii1.&ObjectName..combo1.List(3)
						Else
							.Containercriterii1.&ObjectName..combo1.Value=.Containercriterii1.&ObjectName..combo1.List(4)
						Endif
					Endif
					lcspecial="false"
					If lctext # ""
						.Containercriterii1.&ObjectName..text1.Value = lctext
						.Containercriterii1.&ObjectName..codcriteriu = Substr(lctext,1,At(",",lctext)-1)
						.Containercriterii1.&ObjectName..text1.Visible = .F.
						.Containercriterii1.&ObjectName..ClassId = lcClassId
						.Containercriterii1.&ObjectName..combo1.Width = 275
		
						*!* Aflare nr de ordine din combo
						lnCriteriunr = -1
						For N = 1 To Alen(This.Parent.SelectorCriteriu.acriterii,1)
							If This.Parent.SelectorCriteriu.acriterii(N,7) = Val(Substr(This.Name,13))
								lnCriteriunr=N
							Endif
						Endfor
						lnIndexCriteriu=lnCriteriunr
						*!*
		
						This.Parent.SelectorCriteriu.combo1.List(lnIndexCriteriu)="\]"+This.Parent.SelectorCriteriu.combo1.List(lnIndexCriteriu)
						If(This.Parent.SelectorCriteriu.combo1.ListIndex<This.Parent.SelectorCriteriu.combo1.ListCount-1)
							This.Parent.SelectorCriteriu.combo1.ListIndex=This.Parent.SelectorCriteriu.combo1.ListIndex+1
						Else
							This.Parent.SelectorCriteriu.combo1.ListIndex=This.Parent.SelectorCriteriu.combo1.ListIndex-1
						Endif
		*!*					thhis="lbl_addcriteriu"+Substr(This.Name,13)
		*!*					This.Parent.&thhis.ForeColor=Rgb(225,12,14)		&& rosu
		*!*					This.Parent.combo1.ListIndex=1
						thhis = "lbl_criteriu" + Substr(This.Name,13)
						This.Parent.&thhis..ForeColor = Rgb(15,15,200)		&& albastru
						This.Parent.SelectorCriteriu.combo1.ListIndex = 1
					Endif
		
					If lcTipCriteriu = "E"
						*!* Aflare nr de ordine din combo
						lnCriteriunr=-1
						For N=1 To Alen(This.Parent.SelectorCriteriu.acriterii,1)
							If This.Parent.SelectorCriteriu.acriterii(N,7)=Val(Substr(This.Name,13))
								lnCriteriunr=N
							Endif
						Endfor
						lnIndexCriteriu=lnCriteriunr
						*!*
						This.Parent.SelectorCriteriu.combo1.List(lnIndexCriteriu)="\]"+This.Parent.SelectorCriteriu.combo1.List(lnIndexCriteriu)
		
						If(This.Parent.SelectorCriteriu.combo1.ListIndex<This.Parent.SelectorCriteriu.combo1.ListCount-1)
							This.Parent.SelectorCriteriu.combo1.ListIndex=This.Parent.SelectorCriteriu.combo1.ListIndex+1
						Else
							This.Parent.SelectorCriteriu.combo1.ListIndex=This.Parent.SelectorCriteriu.combo1.ListIndex-1
						Endif
						lcspecial="true"
						This.ForeColor=Rgb(154,154,154)
						This.stare="inactiv"
						This.MousePointer= 0
					Endif
		
					If lcTipCriteriu = "I" And .Containercriterii1.&ObjectName..idValue= ""
						.Containercriterii1.&ObjectName..deleteobj()
					Endif
					.Containercriterii1.&ObjectName..Visible=.T.
					.Refresh()
					*!*				.Containercriterii1.&ObjectName..VISIBLE=.T.
					*!*				.REFRESH()
				Endwith
		
				If lnoftimes=1
					lcoldobj=ObjectName
					templogic =This.Parent.SelectorCriteriu.logic
					*!*	modificare ROAGEST v 2.0.55
					*!*				IF INLIST(lcTipCriteriu, "N", "D", "D1") AND lcspecial="false"
					If Inlist(lcTipCriteriu, "N", "D", "D1") And lcspecial="false" And !This.Parent.lincarcarefiltru
						*!*	modificare ROAGEST v 2.0.55	^
						This.Parent.SelectorCriteriu.logic="SI"
						This.Parent.SelectorCriteriu.lbl_logic.Caption="SI"
					Else
						lnoftimes=3
						This.Parent.SelectorCriteriu.logic=templogic
						This.Parent.SelectorCriteriu.lbl_logic.Caption=templogic
					Endif
				Else
					This.Parent.SelectorCriteriu.logic=templogic
					This.Parent.SelectorCriteriu.lbl_logic.Caption=templogic
					lnoftimes=3
				Endif
				lnoftimes=lnoftimes+1
			Enddo
			*!*	modificare ROAGEST v 2.0.55
			*!*		THIS.PARENT.Containercriterii1.&lcoldobj..text1.SETFOCUS()
			If !This.Parent.lincarcarefiltru
				This.Parent.Containercriterii1.&lcoldobj..text1.SetFocus()
			Else
				If !Empty(Nvl(tnIndex,0))
					This.Parent.Containercriterii1.&ObjectName..combo1.Value = This.Parent.Containercriterii1.&ObjectName..combo1.ListItem(tnIndex)
				Endif
			Endif
			*!*	modificare ROAGEST v 2.0.55	^
			This.Parent.Containercriterii1.do_refresh
			*!*	modificare ROAGEST v 2.0.55
			If !This.Parent.lincarcarefiltru
				This.Parent.Containercriterii1.scroll_bottom()
			Endif
			*!*	modificare ROAGEST v 2.0.55	^
		Endif &&stare diferit de inactiv
		
	ENDPROC

	PROCEDURE MouseEnter
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		IF THIS.stare#"inactiv"
			THIS.FONTBOLD= .T.
		ENDIF
		
	ENDPROC

	PROCEDURE MouseLeave
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		IF THIS.stare#"inactiv"
			THIS.FONTBOLD= .F.
		ENDIF
		
	ENDPROC

ENDDEFINE

DEFINE CLASS cmd_start_criterii AS commandbutton 
 	*< CLASSDATA: Baseclass="commandbutton" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*m: loadcriterii
		*p: pornit
		*a: acriterii[1,4]
	*</DefinedPropArrayMethod>

	*<PropValue>
		Caption = "\<Cauta"
		FontBold = .T.
		Height = 27
		Name = "cmd_start_criterii"
		pornit = nu
		Width = 84
	*</PropValue>
	
	PROCEDURE Click
		LOCAL ARRAY lacriterii(1,1)
		this.loadcriterii(@lacriterii)
		
		if(this.pornit="nu")
			IF NOT PEMSTATUS(this.Parent,"oCriterii",5)
				this.Parent.AddProperty("oCriterii")
			ENDIF
		this.Parent.ocriterii=createOBJECT("frm_criterii",@lacriterii)
		this.pornit="da"
		endif
		
		this.Parent.ocriterii.show(1)
		
		IF NOT PEMSTATUS(this.Parent,"filtru_pretty",5)
			this.Parent.AddProperty("filtru_pretty")
		ENDIF
		IF NOT PEMSTATUS(this.Parent,"filtru_pretty_ro",5)
			this.Parent.AddProperty("filtru_pretty_ro")
		ENDIF	
		thisform.filtru_pretty=this.Parent.ocriterii.filtru
		thisform.filtru_pretty_ro=this.Parent.ocriterii.filtruro
		IF thisform.filtru_pretty_ro#""
		this.ToolTipText=thisform.filtru_pretty_ro
		
		With this.parent
			For i=1 To .Objects.Count
				If Upper(.Objects(i).BaseClass)='CHECKBOX'
					this.ToolTipText=this.ToolTipText + .Objects(i).tag
				Endif
			Endfor
		ENDWITH
		
		ENDIF
		this.setfocus
		
		
		
	ENDPROC

	PROCEDURE KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		
	ENDPROC

	PROCEDURE loadcriterii
		*PARAMETERS tacriterii
		*EXTERNAL ARRAY tacriterii
		*#define crlf CHR(13)+CHR(10)
		*lcStringCriterii="Nume\denumire\T\ID_PART\nom_parteneri" 	+ crlf + ; 
		*				  "Nr. act\nract\N\none\"   				+ crlf + ;
						  "Data act\dataact\D\none\"				+ crlf + ;
						  "Fel document\fel_document\T\none\" 		+ crlf + ;
						  "Cod Fiscal\cod_fiscal\T\none\" 			+ crlf + ;
						  "EroareTVA\nofiled\E\" 					+ ;
						[ AND ABS(TOTCTVA - (RO19B + RO19T + RO9B + RO9T + ROTI + CESCDD1 + CESCDD2 +] + ;
						[WRSCDD + FODD + FOFDD + WRSCFDD + WRN)) >= 1 AND ] + ;
						[ABS(RO19T) BETWEEN ROUND(0.188*ABS(RO19B),?gnPc) AND ROUND(0.193*ABS(RO19B),?gnPc) AND ] + ;
						[ABS(RO9T) BETWEEN ROUND(0.088*ABS(RO9B),?gnPc) AND ROUND(0.093*ABS(RO9B),?gnPc)\ + crlf
		*DODEFAULT()
		*
		*Sunt doua situatii in care poate fi folosit
		*Caption \denumirea campului \ T sau D sau N sau E (text,data,numeric,exceptie)\comanda exceptie\cheia din colectia de nomenclatoare
		*sau
		*Caption \denumirea campului \ T (sa nu fie E)\numele campului din tabela corespondeta formului care apeleaza\cheia din colectia de nomenclatoare
		
		nroflines=ALINES(laCriterii,lcStringCriterii,1,crlf)
		DIMENSION tacriterii(nroflines,5)
		FOR n= 1 TO nroflines
		FOR i = 1 TO 6
			tacriterii(n,i)=GETWORDNUM(laCriterii(n),i,"\")
		ENDFOR
		ENDFOR
		
		
		
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_criterii 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_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Line1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Containercriterii1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_colectienom
		*m: do_incarca_filtre
		*m: getcriteriu
		*m: paramsmatrix
		*p: currentheight
		*p: currentleft
		*p: filtru
		*p: filtrucript		&& Filtru in forma criptata pentru salvare.
		*p: filtruro
		*p: lincarcarefiltru		&& .T. daca se incarca filtrul.
		*p: nr_criterii
		*a: acriterii[1,5]
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 2
		currentheight = 85
		currentleft = 10
		DoCreate = .T.
		filtru = 
		filtrucript = 
		filtruro = 
		Height = 469
		lhide = .T.
		lincarcarefiltru = .F.
		Name = "frm_criterii"
		nr_criterii = 0
		ScrollBars = 2
		Width = 800
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 828
		_shape2.Height = 29
		_shape2.Left = 746
		_shape2.Name = "_shape2"
		_shape2.Top = -1
		_shape2.Width = 57
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Left = 769
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 0
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 741, ;
		Name = "But_renunt1", ;
		Top = 0
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Containercriterii1' AS scontainer WITH ;
		Height = 252, ;
		Left = 12, ;
		Name = "Containercriterii1", ;
		Top = 120, ;
		Width = 784, ;
		up_1.Left = 754, ;
		up_1.Name = "up_1", ;
		up_1.Top = 13, ;
		down_1.Left = 754, ;
		down_1.Name = "down_1", ;
		down_1.Top = 43
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="container" />

	ADD OBJECT 'Line1' AS line WITH ;
		Height = 0, ;
		Left = 0, ;
		Name = "Line1", ;
		Top = 108, ;
		Width = 840
		*< END OBJECT: BaseClass="line" />
	
	PROCEDURE do_colectienom
		** CREARE COLECTIE
		** ==================================================
		LOCAL loHash
		thisform.AddObject("loCol","collection")
		
		*!* nom_parteneri
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_part, denumire, cod_fiscal from nom_parteneri")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire,cod_fiscal,id_part")
			.SetValue("cTitlu", "Alegeti partenerul")
			.SetValue("cTitluColoana", "Nume,Cod fiscal,ID")
			.SetValue("cFiltruOriginal", [STERS = 0 AND INACTIV = 0])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id_Part")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_parteneri")
		
		*!*	modificare migrare v 1.0	>	v 2.0
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "SELECT B.ID_PART, B.DENUMIRE, B.COD_FISCAL " + ;
				" FROM CORESP_TIP_PART A " + ;
				" LEFT JOIN NOM_PARTENERI B ON A.ID_PART = B.ID_PART")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "b.denumire")
			.SetValue("cColoana", "b.denumire,b.cod_fiscal,b.id_part")
			.SetValue("cTitlu", "Alegeti partenerul")
			.SetValue("cTitluColoana", "Nume,Cod fiscal,ID")
			.SetValue("cFiltruOriginal", [B.STERS = 0 AND B.INACTIV = 0 AND A.ID_TIP_PART IN (SELECT id_tip_part FROM coresp_tip_cont WHERE cont = '4111')])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id_Part")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_parteneri4111")
		*!*	modificare migrare v 1.0	>	v 2.0	^
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_responsabil, nume, marca, bi, cnp from vnom_responsabili")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "nume")
			.SetValue("cColoana", "nume, marca, bi, cnp, id_responsabil")
			.SetValue("cTitlu", "Alegeti responsabilul")
			.SetValue("cTitluColoana", "Nume, Marca, BI, CNP, Id")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","nume")
			.setvalue("cidcoloana","id_responsabil")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_responsabil")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_fdoc, fel_document FROM vnom_fdoc")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "fel_document")
			.SetValue("cColoana", "fel_document,id_fdoc")
			.SetValue("cTitlu", "Alegeti felul documentului")
			.SetValue("cTitluColoana", "Document,ID")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","fel_document")
			.setvalue("cidcoloana","id_fdoc")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_feldoc")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select nume_gestiune,cgest,id_gestiune,nr_pag,cont from vnom_gestiuni ")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "nume_gestiune")
			.SetValue("cColoana", "nume_gestiune,cgest")
			.SetValue("cTitlu", "Alegeti Gestiunea")
			.SetValue("cTitluColoana", "Gestiune,Cgest")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","nume_gestiune")
			.setvalue("cidcoloana","id_gestiune")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_gestiune")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select nrord, id_lucrare from vnom_lucrari")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "nrord")
			.SetValue("cColoana", "nrord,id_lucrare")
			.SetValue("cTitlu", "Alegeti lucrarea")
			.SetValue("cTitluColoana", "Lucrare,ID")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","nrord")
			.setvalue("cidcoloana","id_lucrare ")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_lucrare")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_sectie, sectie, csectie FROM vnom_sectii")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "sectie")
			.SetValue("cColoana", "sectie, csectie")
			.SetValue("cTitlu", "Alegeti sectia")
			.SetValue("cTitluColoana", "Sectie, Indicativ")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","sectie")
			.setvalue("cidcoloana","id_sectie")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_sectie")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_valuta, nume_val FROM vnom_valute")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "nume_val")
			.SetValue("cColoana", "nume_val")
			.SetValue("cTitlu", "Alegeti valuta")
			.SetValue("cTitluColoana", "Valuta")
			.SetValue("cFiltruOriginal", [inactiv = 0 and moneda_nationala = 0])
			.setvalue("cresultcoloana","nume_val")
			.setvalue("cidcoloana","id_valuta")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_valuta")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_sucursala, sucursala, inactiv from vnom_sucursale")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "2=2")
			.SetValue("cOrder", "sucursala")
			.SetValue("cColoana", "sucursala,id_sucursala")
			.SetValue("cTitlu", "Alegeti sucursala")
			.SetValue("cTitluColoana", "Sucursala, Id")
			IF glEMama && DACA SUNT PE FIRMA MAMA ARAT DOAR SUCURSALELE EI
				.SetValue("cFiltruOriginal", [inactiv = 0 AND id_mama = ?gnIdFirma])
			ELSE && DACA SUNT PE O SUCURSALA SAU PE FIRMA INDEPENDENTA NU ARAT NIMIC
				.SetValue("cFiltruOriginal", [1=2])
			ENDIF 
			.setvalue("cresultcoloana","sucursala")
			.setvalue("cidcoloana","id_sucursala")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_sucursala")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_util,utilizator from syn_vutilizatori")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "utilizator")
			.SetValue("cColoana", "utilizator")
			.SetValue("cTitlu", "Alegeti utilizatorul")
			.SetValue("cTitluColoana", "Utilizator")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","utilizator")
			.setvalue("cidcoloana","id_util")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_utilizator")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_venchelt, explicatie, (case tip_venchelt when 1 then 'Cheltuiala' else 'Venit' end) as tip_venchelt FROM vnom_venchel")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "explicatie")
			.SetValue("cColoana", "explicatie,tip_venchelt")
			.SetValue("cTitlu", "Alegeti venitul/cheltuiala")
			.SetValue("cTitluColoana", "Explicatia, Tip")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","explicatie")
			.setvalue("cidcoloana","id_venchelt")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_venchel")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select denumire, codmat, um, grupa, subgrupa, id_grupa, id_subgrupa, dnf, cont, acont, inactiv, id_articol from vnom_articole")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire,codmat,um,grupa,subgrupa,cont,acont,dnf,id_articol")
			.SetValue("cTitlu", "Alegeti articolul")
			.SetValue("cTitluColoana", "Denumire,Cod Material,UM,Grupa,Subgrupa,Cont,Analitic,DNF,Id")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id_articol")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_articol")
		thisform.loCol.ADD(loHash, "nom_articole")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select grupa, id_grupa from vgest_art_gr")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "grupa")
			.SetValue("cColoana", "grupa,id_grupa")
			.SetValue("cTitlu", "Alegeti grupa de articole")
			.SetValue("cTitluColoana", "Grupa,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","grupa")
			.setvalue("cidcoloana","id_grupa")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_grupa_articol")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select subgrupa, grupa, id_subgrupa from vgest_art_sbgr")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "subgrupa")
			.SetValue("cColoana", "subgrupa,grupa,id_subgrupa")
			.SetValue("cTitlu", "Alegeti subgrupa de articole")
			.SetValue("cTitluColoana", "Subgrupa,Grupa,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","subgrupa")
			.setvalue("cidcoloana","id_subgrupa")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_subgrupa_articol")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_grupe, nume_grupa, nume_parinte, parent_id FROM vgest_nom_grupe")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "nume_grupa")
			.SetValue("cColoana", "nume_grupa,nume_parinte,id_grupe,parent_id")
			.SetValue("cTitlu", "Alegeti grupa de gestiuni")
			.SetValue("cTitluColoana", "Grupa,Grupa parinte,Id,Id parinte")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","nume_grupa")
			.setvalue("cidcoloana","id_grupe")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_grupa_gestiune")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_meseria, meserie from SAL_VNOM_MES")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "meserie")
			.SetValue("cColoana", "id_meseria, meserie")
			.SetValue("cTitlu", "Alegeti meseria")
			.SetValue("cTitluColoana", "Meseria, Id")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","meserie")
			.setvalue("cidcoloana","meseria")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_meserie")
		
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_formatia, denumire, sectie from sal_vnom_formatii")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire, id_formatia, sectie")
			.SetValue("cTitlu", "Alegeti formatia")
			.SetValue("cTitluColoana", "Formatia, Id, Sectie")
			.SetValue("cFiltruOriginal", [inactiv = 0])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id_formatia")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_formatie")
		
		*!* tip_rulaj
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_tip_rulaj,descriere from nom_tip_rulaj")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "2=2")
			.SetValue("cOrder", "descriere")
			.SetValue("cColoana", "descriere,id_tip_rulaj")
			.SetValue("cTitlu", "Alegeti tipul de rulaj")
			.SetValue("cTitluColoana", "Descriere,ID")
			.SetValue("cFiltruOriginal", [STERS = 0])
			.setvalue("cresultcoloana","descriere")
			.setvalue("cidcoloana","id_tip_rulaj")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_tip_rulaj")
		
		*!* nom_contracte
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_ctr, id_part, denumire, contract, numar, data from vcontracte")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "data desc, numar")
			.SetValue("cColoana", "contract,denumire,id_ctr")
			.SetValue("cTitlu", "Alegeti contractul")
			.SetValue("cTitluColoana", "Contract,Partener,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","contract")
			.setvalue("cidcoloana","id_ctr")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_contracte")
		
		*!* tip_contract
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_tip_ctr,denumire from tipuri_contracte")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "2=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire,id_tip_ctr")
			.SetValue("cTitlu", "Alegeti tipul de contract")
			.SetValue("cTitluColoana", "Denumire,ID")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id_tip_ctr")
		ENDWITH
		thisform.loCol.ADD(loHash, "tipuri_contracte")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_transa, transa from sal_vnom_transe")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "transa")
			.SetValue("cColoana", "transa, id_transa")
			.SetValue("cTitlu", "Alegeti transa")
			.SetValue("cTitluColoana", "Transa, Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","transa")
			.setvalue("cidcoloana","id_transa")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_transe")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id, denumire,valoare from sal_vnom_tichete")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire, valoare, id")
			.SetValue("cTitlu", "Alegeti tipul tichetului")
			.SetValue("cTitluColoana", "Tip tichet,Valoare, Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_tichete")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id, denumire, sters, inactiv, id_util, dataora, id_utils, dataoras from vnom_locatii")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire,id")
			.SetValue("cTitlu", "Alegeti locatia")
			.SetValue("cTitluColoana", "Denumire,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_locatii")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id, denumire from fact_tipuri")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "denumire")
			.SetValue("cColoana", "denumire,id")
			.SetValue("cTitlu", "Alegeti tipul facturii")
			.SetValue("cTitluColoana", "Denumire,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","denumire")
			.setvalue("cidcoloana","id")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_tipfactura")
		
		loHash = GetHash()
		WITH loHash
			.SetValue("cSelect", "select id_ruta, ruta from fact_nom_rute")
			.SetValue("cSchema", "")
			.SetValue("cFiltru", "1=2")
			.SetValue("cOrder", "ruta")
			.SetValue("cColoana", "denumire,id")
			.SetValue("cTitlu", "Alegeti ruta")
			.SetValue("cTitluColoana", "Ruta,Id")
			.SetValue("cFiltruOriginal", [])
			.setvalue("cresultcoloana","ruta")
			.setvalue("cidcoloana","id_ruta")
		ENDWITH
		thisform.loCol.ADD(loHash, "nom_ruta")	
	ENDPROC

	PROCEDURE do_incarca_filtre
		Lparameters tcFiltru
		
		
		Local lcDelimitator,lcDelimitator2,lnNr,lnNrTemp
		Thisform.lincarcarefiltru = .T.
		lcDelimitator = [|]
		lcDelimitator2 = [;]
		For lnNr = 1 To Getwordcount(tcFiltru,lcDelimitator)
			lnNrTemp = lnNr
			lcSir = Getwordnum(tcFiltru,lnNr,lcDelimitator)
			Do Case
			Case lcSir = [(]
				Thisform.SelectorCriteriu.cmd_OpenGroup.Click()
			Case lcSir = [)]
				Thisform.SelectorCriteriu.cmd_CloseGroup.Click()
			Case Inlist(lcSir,[SI],[SAU])
				If lcSir <> Thisform.SelectorCriteriu.logic
					Thisform.SelectorCriteriu.lbl_logic.Click()
				Endif
			Otherwise
				lcCaption = Substr(lcSir,1,At(lcDelimitator2,lcSir,1)-1)
				lcCamp = Substr(lcSir,At(lcDelimitator2,lcSir,1)+1,At(lcDelimitator2,lcSir,2)-At(lcDelimitator2,lcSir,1)-1)
				lcIndex = Substr(lcSir,At(lcDelimitator2,lcSir,2)+1,At(lcDelimitator2,lcSir,3)-At(lcDelimitator2,lcSir,2)-1)
				lcId = Substr(lcSir,At(lcDelimitator2,lcSir,3)+1,At(lcDelimitator2,lcSir,4)-At(lcDelimitator2,lcSir,3)-1)
				lcValoare = Substr(lcSir,At(lcDelimitator2,lcSir,4)+1)
				For N= 1 To Alen(Thisform.acriterii,1)
					lcNumeObiect = "Thisform.lbl_Criteriu" + Transform(N)
					loObiect = &lcNumeObiect
		*!*	modificare ROAGEST v 2.0.64
		*!*				If Alltrim(Upper(loObiect.Caption)) = Alltrim(Upper(lcCaption)) ;
		*!*						and Alltrim(Upper(Thisform.SelectorCriteriu.acriteriiuns(N,2))) = Alltrim(Upper(lcCamp))
					If Alltrim(Upper(loObiect.Caption)) = Alltrim(Upper(lcCaption)) ;
							and Alltrim(Upper(Strtranx(Thisform.SelectorCriteriu.acriteriiuns(N,2),"([^a-zA-Z0-9])",[])))= Alltrim(Upper(strtranx(lcCamp,"([^a-zA-Z0-9])",[])))
		*!*	modificare ROAGEST v 2.0.64
						loObiect.do_initializeaza(Iif(Nvl(lcIndex,[])<>[],Val(lcIndex),.Null.),;
							Iif(Nvl(lcId,[])<>[],Val(lcId),.Null.),;
							lcValoare)
						Exit
					Endif
				Endfor
			Endcase
			lnNr = lnNrTemp
		Endfor
		Thisform.lincarcarefiltru = .F.
		Thisform.inainte_de_do_termin()
	ENDPROC

	PROCEDURE do_renunt
		IF THIS.inainte_de_do_renunt()
			gnButon = 2
			pnButon = 2
			Buton = 2
			pnIesire = 2
			THIS.filtru="none"
			THIS.VISIBLE= .F.
		ENDIF
		
	ENDPROC

	PROCEDURE getcriteriu
		LPARAMETERS tcNumeCriteriu
		&& tcNumeCriteriu : numele unui criteriu sau nimic
		&& creeaza o colectie cu aparitiile criteriului sau ale tuturor criteriilor din fereastra de cautare
		
		LOCAL loCollection AS COLLECTION
		LOCAL i, lnNrTotalCriterii, lcNumeCriteriu, lnRanduri
		LOCAL lcNumeCriteriuCurent, lcOperatorCriteriuCurent, lcValoareCriteriuCurent
		EXTERNAL ARRAY taListaValori
		
		IF EMPTY(tcNumeCriteriu) OR TYPE('tcNumeCriteriu') <> 'C'
			lcNumeCriteriu = ""
		ELSE
			lcNumeCriteriu = UPPER(ALLTRIM(tcNumeCriteriu))
		ENDIF
		loCollection = CREATEOBJECT("collection")
		
		lnRanduri = 1
		lnNrTotalCriterii = THIS.nr_criterii
		FOR i = 1 TO lnNrTotalCriterii
			lcCriteriu = "Criteriu" + ALLTRIM(STR(i))
			loCriteriu = THIS.containercriterii1.&lcCriteriu
			IF !INLIST(loCriteriu.TAG, "GroupOpen", "GroupClose", "Sters")
				lcNumeCriteriuCurent = UPPER(ALLTRIM(loCriteriu.lbl_Criteriu.CAPTION))
				lcOperatorCriteriuCurent = loCriteriu.combo1.VALUE
				lcValoareCriteriuCurent = loCriteriu.text1.VALUE
				lcIdCampCriteriuCurent = loCriteriu.idcamp
				lcIdValoareCriteriuCurent = loCriteriu.idvalue
				lcTipCriteriu = UPPER(THISFORM.acriterii(loCriteriu.criteriu_nr,3))
				lcOperatorCriteriuCurentInfo = ""
				DO CASE
					CASE INLIST(lcOperatorCriteriuCurent, "egala", "egal")
						lcOperatorCriteriuCurentInfo = "="
					CASE INLIST(lcOperatorCriteriuCurent, "diferita", "diferit")
						lcOperatorCriteriuCurentInfo = "<>"
					CASE INLIST(lcOperatorCriteriuCurent, "mai mare")
						lcOperatorCriteriuCurentInfo = "<>"
					CASE INLIST(lcOperatorCriteriuCurent, "mai mica", "mai mic")
						lcOperatorCriteriuCurentInfo = "<"
					CASE INLIST(lcOperatorCriteriuCurent, "mai mica sau egala", "mai mic sau egal")
						lcOperatorCriteriuCurentInfo = "<="
					CASE INLIST(lcOperatorCriteriuCurent, "mai mare sau egala", "mai mare sau egal")
						lcOperatorCriteriuCurentInfo = ">="
					CASE INLIST(lcOperatorCriteriuCurent, "Lista...")
						lcOperatorCriteriuCurentInfo = "="
						*			CASE INLIST(lcOperatorCriteriuCurent, "are valori", "nu are valori")
				ENDCASE
		
		
				IF EMPTY(lcNumeCriteriu) OR (!EMPTY(lcNumeCriteriu) AND lcNumeCriteriuCurent == lcNumeCriteriu)
					loChild = CREATEOBJECT("empty")
					ADDPROPERTY(loChild,"criteriu", lcNumeCriteriuCurent)
					ADDPROPERTY(loChild,"operator_ro", lcOperatorCriteriuCurent)
					ADDPROPERTY(loChild,"operator", lcOperatorCriteriuCurentInfo)
					ADDPROPERTY(loChild,"valoare", lcValoareCriteriuCurent)
					ADDPROPERTY(loChild,"idcamp", lcIdCampCriteriuCurent)
					ADDPROPERTY(loChild,"idvaloare", lcIdValoareCriteriuCurent)
					loCollection.ADD(loChild)
					RELEASE loChild
				ENDIF
			ENDIF
		ENDFOR
		
		RETURN loCollection
	ENDPROC

	PROCEDURE Hide
		gfiltru=this.filtru
		gfiltruro=this.filtruro
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		*!* 19.12.2014
		*!* marius.mutu
		*!* am pus temporar lcThislogic = '~~' + lcThislogic ca sa nu se incurce cu SI/SAU din conditie
		
		*!*	05.03.2015
		*!*	marius.mutu
		*!*	Daca am o Expresie |E|ID_PARTD=<<VALOARE>> OR ID_PARTC=<<VALOARE>> pe campul lcCampId, se inlocuieste <<VALOARE>> cu partenerul ales din nomenclator
		*!*	Se foloseste in Registrul Jurnal la cautarea dupa Partener D&C. Conpress folosea cautare neoptimizata in Explicatii
		
		Local lcTipCriteriu, luValoareCriteriu, lcTag, lcLogic
		Local lcCaption, lcConditieSpeciala, lcIdValue, lcIdCamp, lcCodCriteriu, lcNumeCriteriu, lcValoareCript
		Local lcFiltru, lcFiltruRo, lcFiltruCript
		lcFiltru = ""
		lcFiltruRo = ""
		lcFiltruCript = ""
		*!*	 elementele posibile din lcFiltruCript : 'SI|', 'SAU|', '(|', '|)', 'caption;camp;index lista;id;valoarecamp|'
		Private pcerrorstr
		pcerrorstr=""
		lnpdeschis=0
		lnpinchis=0
		lnsterse=0
		lcFiltru=""
		*!*	If MessageBox("Debug?",4,"Atentie")=6
		*!*		Debug
		*!*		suspend
		*!*	EndIf
		For N= 1 To Thisform.nr_criterii
			ObjectName="Criteriu"+Transform(N)
		
			If Thisform.Containercriterii1.&ObjectName..Tag="GroupOpen"
				lnpdeschis=lnpdeschis+1
			Endif && Numara toate parantezele deschise
		
			If Thisform.Containercriterii1.&ObjectName..Tag="GroupClose"
				lnpinchis=lnpinchis+1
			Endif && Numara toate parantezele inchise
		
			If Thisform.Containercriterii1.&ObjectName..Tag="Sters"
				lnsterse=lnsterse+1
			Endif && Numara toate obiectele sterse
		
		Endfor &&Parcurge toate obiectele de pe forma
		
		If lnpdeschis<>lnpinchis
			pcerrorstr=pcerrorstr+"Grupurile nu se potrivesc"+Chr(13)+Chr(10)
		Endif && Daca nr de paranteze deschise nu este acelasi cu nr de paranteze deschise
		&&    (parantezele nu se pot sterge)
		
		If lnpdeschis+lnpinchis=Thisform.nr_criterii-lnsterse And Thisform.nr_criterii>0 And lnsterse#Thisform.nr_criterii
			pcerrorstr=pcerrorstr+"Va trebuie un criteriu valid, nu numai grupuri"+Chr(13)+Chr(10)
		Endif && daca suma obiectelor nesterse este egala cu suma parantezelor inseamna ca
		&&  s-au introdus numai paranteze si niciun criteriu logic
		
		
		*!* 	  ***                ***                ***                      ***
		*                          incheiere verificare erori
		*!* 	  ***                ***                ***                      ***
		
		*Parcurgere criterii pentru limba romana
		lcFiltruRo=""
		For nn =1 To Thisform.nr_criterii
			ObjectName="Criteriu"+Transform(nn)
			If Thisform.Containercriterii1.&ObjectName..Tag#"Sters"
				If Thisform.Containercriterii1.&ObjectName..Tag="GroupOpen" Or Thisform.Containercriterii1.&ObjectName..Tag="GroupClose"
					lcFiltruRo=lcFiltruRo + [ ] + Alltrim(Thisform.Containercriterii1.&ObjectName..Caption)
					Loop
				Endif
		
				lcTipCriteriu = Upper(Thisform.acriterii(Thisform.Containercriterii1.&ObjectName..criteriu_nr,3))
				If At('|', lcTipCriteriu) > 0
					lcTipCriteriu = Left(lcTipCriteriu, At('|', lcTipCriteriu) -1) && tipul criteriului N|GetMask(12,gnPA)
				Endif
		
				*!* prepozitie operator
				lcPrepop = Alltrim(Thisform.Containercriterii1.&ObjectName..Combo1.List(Thisform.Containercriterii1.&ObjectName..Combo1.ListIndex))
				lcPrepop1 = ""
				Do Case
					Case lcTipCriteriu = "E"
						* NU FAC NIMIC
					Case lcPrepop = "egala"
						lcPrepop1 = [ cu ']
					Case lcPrepop = "egal"
						lcPrepop1 = [ cu ']
					Case lcPrepop = "diferita"
						lcPrepop1 = [ de ']
					Case lcPrepop = "diferit"
						lcPrepop1 = [ de ']
					Case lcPrepop = "mai mare"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mica"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mic"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mica sau egala"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mare sau egala"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mica sau egal"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mare sau egal"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "mai mic sau egal"
						lcPrepop1 = [ decat ']
					Case lcPrepop = "Lista..."
						lcFiltruRo=Strtran(lcFiltruRo,"Lista... "," este ")
						lcPrepop1 = [ ']
					Case Inlist(lcPrepop, "are valori", "nu are valori")
						lcPrepop1 = [ ]
					Otherwise
						lcPrepop1 = [ ']
				Endcase
		
				*!* Spatiu + Operator logic + NumeCriteriu  + operator
				Do Case
					Case lcTipCriteriu = 'E' && Spatiu + Operator logic + NumeCriteriu
						lcFiltruRo = lcFiltruRo + [ ] + '~~'+Thisform.Containercriterii1.&ObjectName..logic + [ ] + Thisform.Containercriterii1.&ObjectName..numecriteriu + [ ]
					Otherwise
						lcFiltruRo = lcFiltruRo + [ ] + '~~'+Thisform.Containercriterii1.&ObjectName..logic + [ ] + Thisform.Containercriterii1.&ObjectName..numecriteriu + [ ]+ ;
							lcPrepop + lcPrepop1
				Endcase
		
				*!*			lcPrepop1 = ""
				*!*			DO CASE
				*!*				CASE lcTipCriteriu = "E"
				*!*					* NU FAC NIMIC
				*!*					lcPrepop = ""
				*!*				CASE lcPrepop = "egala"
				*!*					lcPrepop = "="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "egal"
				*!*					lcPrepop = "="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "diferita"
				*!*					lcPrepop = "<>"
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "diferit"
				*!*					lcPrepop = "<>"
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mare"
				*!*					lcPrepop = ">"
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mica"
				*!*					lcPrepop = "<"
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mic"
				*!*					lcPrepop = "<"
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mica sau egala"
				*!*					lcPrepop = "<="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mare sau egala"
				*!*					lcPrepop = ">="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mica sau egal"
				*!*					lcPrepop = "<="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mare sau egal"
				*!*					lcPrepop = ">="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "mai mic sau egal"
				*!*					lcPrepop = "<="
				*!*					lcPrepop1 = [ ']
				*!*				CASE lcPrepop = "Lista..."
				*!*					lcPrepop = "="
				*!*					lcPrepop1 = [ ']
				*!*				OTHERWISE
				*!*					lcPrepop = ""
				*!*			ENDCASE
		
				*!*			*!* Spatiu + Operator logic + NumeCriteriu  + operator
				*!*			DO CASE
				*!*				CASE lcTipCriteriu = 'E' && Spatiu + Operator logic + NumeCriteriu
				*!*					lcFiltruRo = lcFiltruRo + [ ] + THISFORM.Containercriterii1.&ObjectName..logic + [ ] + THISFORM.Containercriterii1.&ObjectName..numecriteriu + [ ]
				*!*				OTHERWISE
				*!*					lcFiltruRo = lcFiltruRo + [ ] + THISFORM.Containercriterii1.&ObjectName..logic + [ ] + THISFORM.Containercriterii1.&ObjectName..numecriteriu + [ ]+ ;
				*!*						lcPrepop + lcPrepop1
				*!*			ENDCASE
		
				luValoareCriteriu = Thisform.Containercriterii1.&ObjectName..Text1.Value
		
				&& FILTRU ROMANA
				If(Thisform.Containercriterii1.&ObjectName..Text1.Visible=.T.)
					Do Case
						Case lcTipCriteriu = "D1"
							lcFiltruRo = lcFiltruRo + luValoareCriteriu + [' ]
						Case lcTipCriteriu = "D"
							lcdate = Alltrim(Dtos(luValoareCriteriu))
							lcy = Substr(lcdate,1,4)
							lcm = Substr(lcdate,5,2)
							lcd = Substr(lcdate,7,2)
							lcFiltruRo = lcFiltruRo + lcd + "-" + lcm + "-" + lcy + [' ]
						Case lcTipCriteriu = "N"
							lcFiltruRo = lcFiltruRo + Alltrim(Transform(luValoareCriteriu)) + [' ]
						Case lcTipCriteriu = "E" Or Inlist(lcPrepop, "are valori", "nu are valori")
							* NU FAC NIMIC
						Otherwise
							lcFiltruRo = lcFiltruRo+Strtran(Alltrim(luValoareCriteriu),"'",[]) + [']
					Endcase
		
				Endif
			Endif
		Endfor
		
		*Parcurgere criterii
		For N= 1 To Thisform.nr_criterii
			ObjectName="Criteriu"+Transform(N)
			lcTag = Thisform.Containercriterii1.&ObjectName..Tag
			lcLogic = Thisform.Containercriterii1.&ObjectName..logic
		
			If lcTag # "Sters"
				If Inlist(lcTag, "GroupOpen", "GroupClose")
					lcCaption = Thisform.Containercriterii1.&ObjectName..Caption
					lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + [ ] + Right(Alltrim(lcCaption),1)+ [ ]
					*!*	modificare	ROAGEST v 2.0.55
					lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,[])),lcLogic + [|],[]) + ;
						RIGHT(Alltrim(lcCaption),1)+ [|]
					*!*	modificare	ROAGEST v 2.0.55	^
					&&   Daca obiectul curent este o paranteza
				Else
					&&	 Daca obiectul curent nu este o paranteza
					lcTipCriteriu = Thisform.acriterii(Thisform.Containercriterii1.&ObjectName..criteriu_nr,3)
					If At('|', lcTipCriteriu) > 0
						lcTipCriteriu = Left(lcTipCriteriu, At('|', lcTipCriteriu) -1) && tipul criteriului N|GetMask(12,gnPA)
					Endif
					luValoareCriteriu = Thisform.Containercriterii1.&ObjectName..Text1.Value
					*!*	modificare	ROAGEST v 2.0.55
					lcCaption = Thisform.Containercriterii1.&ObjectName..lbl_criteriu.Caption
					Do Case
						Case lcTipCriteriu = "D"
							lcValoareCript = Dtoc(luValoareCriteriu)
						Case lcTipCriteriu = "N"
							lcValoareCript = Alltrim(Str(luValoareCriteriu,20,gnPCant))
						Otherwise
							lcValoareCript = Upper(luValoareCriteriu)
					Endcase
					*!*	modificare	ROAGEST v 2.0.55	^
		
					* "Explicatie D&C\partd,partc\T\|E|ID_PARTD=<<VALOARE>> OR ID_PARTC=<<VALOARE>>\nom_parteneri"
					lcConditieSpeciala = Thisform.acriterii(Thisform.Containercriterii1.&ObjectName..criteriu_nr,4)
					lcIdValue = Thisform.Containercriterii1.&ObjectName..idValue
					lcIdCamp = Thisform.Containercriterii1.&ObjectName..idCamp
					lcCodCriteriu = Thisform.Containercriterii1.&ObjectName..codcriteriu
					lcNumeCriteriu=This.acriterii(Thisform.Containercriterii1.&ObjectName..criteriu_nr,2)
		
					If lcTipCriteriu = "E"
						lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + [ ] + lcConditieSpeciala + [ ]
						*!*	modificare	ROAGEST v 2.0.55
						lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
							ALLTRIM(lcCaption) + [;] + strtranx(lcNumeCriteriu,"([^a-zA-Z0-9])",[]) + [;;;|]
						*!*	modificare	ROAGEST v 2.0.55	^
						&& Daca obiectul curent este un criteriu special atunci
						&& copiaza codul special din array si opreste parcurgerea obiectelor
						Loop
					Endif
		
					&& daca am completat camp id (obtinut din caut_alfa)
					If lcIdValue # ""
						*!* 21.11.2007
						&& VERIFIC DACA AM O EXPRESIE COMPLEXA |E| in loc de o lista de coloane
						&& INLOCUIESC <<VALOARE> CU lcIdValue
						DO CASE 			
							CASE '|E|'$lcNumeCriteriu
								lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + " (" + Strtran(Substr(Upper(lcNumeCriteriu),4), [<<VALOARE>>], lcIdValue) + ")"
								*!*	modificare	ROAGEST v 2.0.55
								lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
									ALLTRIM(lcCaption) + [;] + ;
									strtranx(lcNumeCriteriu,"([^a-zA-Z0-9])",[]) + [;;] + lcIdValue + [;] + lcValoareCript + [|]
								*!*	modificare	ROAGEST v 2.0.55	^
							CASE '|E|'$lcIdCamp && |E|ID_PARTD=<<VALOARE>> OR ID_PARTC=<<VALOARE>>
								lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + " (" + Strtran(Substr(Upper(lcIdCamp),4), [<<VALOARE>>], lcIdValue) + ")"
								lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
									ALLTRIM(lcCaption) + [;] + ;
									strtranx(lcIdCamp,"([^a-zA-Z0-9])",[]) + [;;] + lcIdValue + [;] + lcValoareCript + [|]
														
							OTHERWISE 
								lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + " " + lcIdCamp + "=" + lcIdValue
								*!*	modificare	ROAGEST v 2.0.55
								lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
									ALLTRIM(lcCaption) + [;] + ;
									lcNumeCriteriu + [;] + ;
									Alltrim(Str(Thisform.Containercriterii1.&ObjectName..Combo1.ListIndex)) + [;] + ;
									lcIdValue + [;] + ;
									lcValoareCript + [|]
								*!*	modificare	ROAGEST v 2.0.55	^
							ENDCASE 
						Loop
					Endif
		
					If lcTipCriteriu = "A"
						lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + [ (] + lcCodCriteriu +[) ]
						*!*	modificare	ROAGEST v 2.0.55
						lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
							ALLTRIM(lcCaption) + [;] + ;
							lcNumeCriteriu + [;] + ;
							Alltrim(Str(Thisform.Containercriterii1.&ObjectName..Combo1.ListIndex)) + [;] + ;
							lcIdValue + [;|]
						*!*	modificare	ROAGEST v 2.0.55	^
						&& Daca obiectul curent este un criteriu special atunci
						&& copiaza codul special din array si opreste parcurgerea obiectelor
						Loop
					Endif
		
					lcExpresie = Alltrim(Thisform.Containercriterii1.&ObjectName..Combo1.List(Thisform.Containercriterii1.&ObjectName..Combo1.ListIndex))
					Do Case
						Case lcTipCriteriu = "D1"
							lcvaloare = Alltrim(Str(Round(Val(Substr(luValoareCriteriu, 4))*12 + Val(Left(luValoareCriteriu, 2)),0)))
							&& perioada = an*12+luna
						Case lcTipCriteriu = "D"
							lcvaloare = Alltrim(Dtos(luValoareCriteriu))
							&& data YYYYMMDD
						Case lcTipCriteriu = "N"
							lcvaloare = Alltrim(Transform(luValoareCriteriu))
						Otherwise
							lcvaloare = Strtran(Alltrim(luValoareCriteriu),"'",[''])
					Endcase && Preluarea valorilor se face diferit in functie de tipul criteriului
					&& mai exact daca este de tip data
					*!*	modificare	ROAGEST v 2.0.55
					lcFiltruCript = lcFiltruCript + Iif(!Empty(Nvl(lcLogic,'')),lcLogic + [|],[]) + ;
						ALLTRIM(lcCaption) + [;] + ;
						Alltrim(lcNumeCriteriu) + [;] + ;
						Alltrim(Str(Thisform.Containercriterii1.&ObjectName..Combo1.ListIndex)) + [;] + ;
						Alltrim(lcIdValue) + [;] + Alltrim(lcValoareCript) + [|]
					*!*	modificare	ROAGEST v 2.0.55	^
					criteriustring=""
					*!*		lcnumecriteriu=thisform.&ObjectName..numecriteriu
		
					*!* 21.11.2007
					&& VERIFIC DACA AM O EXPRESIE COMPLEXA |E| in loc de o lista de coloane
					If !'|E|'$lcNumeCriteriu
						*!*				 modificare ROACONT v 2.0.74 : UPPER
						Alines(Campuri, Upper(lcNumeCriteriu),2,",")
						*!*				 modificare ROACONT v 2.0.74 ^
					Else
						Dimension Campuri(1)
						Campuri(1) = Substr(lcNumeCriteriu, 4)
					Endif
					*!* 21.11.2007 ^
					If Alen(Campuri)>1
						lcFiltru = lcFiltru + [ ] + '~~'+lcLogic + " ("
					Endif
					For NrCampuri = 1 To Alen(Campuri)
						If lcTipCriteriu = "D"
							Do Case
									******************************************************************************************************
									*************    *    Criterii de tip Data    *   ****************************************************
									*************************************************************************************************CV***
								Case lcExpresie = "egala"																		&&
									criteriustring = [= To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
								Case lcExpresie = "diferita"																	&&
									criteriustring = [<> To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
								Case lcExpresie = "mai mica"																	&&
									criteriustring = [< To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
								Case lcExpresie = "mai mica sau egala"															&&
									criteriustring = [<= To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
								Case lcExpresie = "mai mare sau egala"															&&
									criteriustring = [>= To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
								Case lcExpresie = "mai mare"																	&&
									criteriustring = [> To_Date('] + lcvaloare + [','YYYYMMDD')]	&&
							Endcase																									&&
							******************Formarea stringului*********************************************************************
		
						Else && daca criteriul curent nu este de tip data(inseamna ca este numar sau text- cazurile speciale a fost tratat la inceput)
							Do Case
									**********************************************************************
									*************    *    Criterii de tip text    *   ********************
									******************************************************************CV**
								Case '|E|'$lcNumeCriteriu
									*!* 21.11.2007
									&& VERIFIC DACA AM O EXPRESIE COMPLEXA |E| in loc de o lista de coloane
									&& INLOCUIESC <<Valoare>> cu lcValoare
									criteriustring = Strtran(Substr(Upper(lcNumeCriteriu),4), [<<VALOARE>>], lcvaloare)
								Case lcExpresie="incepe cu"										&&
									criteriustring= [LIKE '] + Upper(lcvaloare) + [%']			&&
								Case lcExpresie="este"											&&
									criteriustring=[='] + Upper(lcvaloare) + [']				&&
								Case lcExpresie="nu este"										&&
									criteriustring=[!='] + Upper(lcvaloare) + [']				&&
								Case lcExpresie="contine"										&&
									criteriustring= [LIKE '%] + Upper(lcvaloare) + [%']			&&
								Case lcExpresie="nu contine"									&&
									criteriustring= [NOT LIKE '%] + Upper(lcvaloare) + [%']		&&
								Case lcExpresie="nu are valori"									&&
									criteriustring= [is null]									&&
								Case lcExpresie="are valori"									&&
									criteriustring= [is not null]								&&
									******************criterii numerice***********************************
								Case lcExpresie="mai mare sau egal"								&&
									criteriustring = [>=]+Iif(lcvaloare="","0",lcvaloare)	    &&
								Case lcExpresie="mai mic sau egal"								&&
									criteriustring = [<=]+Iif(lcvaloare="","0",lcvaloare)		&&
								Case lcExpresie="egal"											&&
									criteriustring = [=]+Iif(lcvaloare="","0",lcvaloare)   		&&
								Case lcExpresie="diferit"										&&
									criteriustring = [<>]+Iif(lcvaloare="","0",lcvaloare) 		&&
								Case lcExpresie="mai mic"										&&
									criteriustring = [<]+Iif(lcvaloare="","0",lcvaloare) 		&&
								Case lcExpresie="mai mare"										&&
									criteriustring = [>]+Iif(lcvaloare="","0",lcvaloare) 		&&
							Endcase																&&
							******************Formarea stringului*************************************
						Endif && Verifica tipului de criteriu
						If NrCampuri > 1
							lcThislogic = "SAU"
						Else
							If Alen(Campuri) > 1
								lcThislogic = ""
							Else
								lcThislogic = lcLogic
							Endif
						ENDIF
						IF !EMPTY(m.lcThislogic)
							m.lcThislogic = '~~'+m.lcThislogic
						ENDIF 
						
						*!*	modificare ROAGEST v 2.0.118
						*!*					*!*	        modificare ROACONT v 2.0.74 : UPPER
						*!*					lcFiltru= lcFiltru + [ ] + lcThislogic + [ UPPER(] + Alltrim(Campuri(NrCampuri)) + [) ] ;
						*!*						+ criteriustring
						*!*					*!*	        modificare ROACONT v 2.0.74 ^
						If Inlist(lcTipCriteriu ,[D],[D1],[N],[E],[A])
							lcFiltru= lcFiltru + [ ] + '~~'+lcThislogic + [ ] + Alltrim(Campuri(NrCampuri)) + [ ] + criteriustring
						ELSE
							* pentru cautare dupa SCD, SCC (in registrul jurnal) nu fac UPPER(SCD/SCC) = XXX pentru ca nu se foloseste cautarea dupa index ACT.IDX_ACT_006 (SCD, SCC)
							IF INLIST(LOWER(Alltrim(Campuri(NrCampuri))), 'scd', 'scc')
								lcFiltru= lcFiltru + [ ] + '~~'+lcThislogic + [ ] + Alltrim(Campuri(NrCampuri)) + [ ] + criteriustring
							ELSE 	
								lcFiltru= lcFiltru + [ ] + '~~'+lcThislogic + [ UPPER(] + Alltrim(Campuri(NrCampuri)) + [) ] + criteriustring
							ENDIF 	
						Endif
						*!*	modificare ROAGEST v 2.0.118	^
						If NrCampuri=Alen(Campuri) And NrCampuri > 1
							lcFiltru= lcFiltru +")"
						Endif
		
					Endfor && NrCampuri = 1 TO ALEN(Campuri)
					NrCampuri=0
					Release Campuri
				Endif && Verifica daca obiectul curent a fost operator de grup sau criteriu
			Endif && Verifica daca obiectul nu este sters
		Endfor && Parcurge toate obiectele de pe forma
		
		*!*	lcFiltru=Strtran(lcFiltru, " SI ", " AND ")
		*!*	lcFiltru=Strtran(lcFiltru, " SAU ", " OR ")
		lcFiltru=Strtran(lcFiltru, " ~~~~SI ", " AND ")
		lcFiltru=Strtran(lcFiltru, " ~~~~SAU ", " OR ")
		
		lcFiltru=Strtran(lcFiltru, " ~~SI ", " AND ")
		lcFiltru=Strtran(lcFiltru, " ~~SAU ", " OR ")
		
		Do While At("  ",lcFiltru)>0
			lcFiltru=Strtran(lcFiltru,"  "," ")
		Enddo &&Scoate spatiile goale(din 2 spatii goale consecutive transforma in 1)
		
		Do While At("( )",lcFiltru)>0 Or At("( AND )",lcFiltru)>0 Or At("( OR )",lcFiltru)>0 Or At("(  )",lcFiltru)>0 Or At("( AND",lcFiltru)>0 Or At("( OR",lcFiltru)>0
			lcFiltru=Strtran(lcFiltru,"AND ( )","")
			lcFiltru=Strtran(lcFiltru,"OR ( )","")
			lcFiltru=Strtran(lcFiltru,"AND (  )","")
			lcFiltru=Strtran(lcFiltru,"OR (  )","")
			lcFiltru=Strtran(lcFiltru,"( )","")
			lcFiltru=Strtran(lcFiltru,"( AND )","")
			lcFiltru=Strtran(lcFiltru,"( OR )","")
			lcFiltru=Strtran(lcFiltru,"( AND","(")
			lcFiltru=Strtran(lcFiltru,"( OR","(")
		
			Do While At("  ",lcFiltru)>0
				lcFiltru=Strtran(lcFiltru,"  "," ")
			Enddo
		Enddo && Curatare siruri goale, paranteze goale, si conditii logice goale "recursiv"
		
		lcFiltru = Alltrim(lcFiltru)
		lcFiltruRo = Alltrim(lcFiltruRo)
		If At("AND", lcFiltru) = 1
			lcFiltru = Substr(lcFiltru, 4)
		Endif && curatare AND/OR de la inceputul conditiei
		If At("OR", lcFiltru) = 1
			lcFiltru = Substr(lcFiltru, 3)
		Endif && curatare AND/OR de la inceputul conditiei
		
		If At("SI", lcFiltruRo) = 1
			lcFiltruRo = Substr(lcFiltruRo, 3)
		Endif && curatare SI/SAU de la inceputul conditiei
		If At("SAU", lcFiltruRo) = 1
			lcFiltruRo = Substr(lcFiltruRo, 4)
		Endif && curatare SI/SAU de la inceputul conditiei
		
		If Len(pcerrorstr)>0
			AMESSAGEBOX(pcerrorstr,16)
			Return .F. && Daca au survenit erori
		Else
			lcFiltruRO = STRTRAN(m.lcFiltruRO, '~~', '')
			lcFiltru = STRTRAN(m.lcFiltru, '~~', '')
			lcFiltruCript = STRTRAN(m.lcFiltruCript, '~~', '')
			
			This.filtruro =Alltrim(lcFiltruRo)
			This.filtru= Alltrim(lcFiltru)
			*!*	modificare	ROAGEST v 2.0.55
			This.filtrucript = Alltrim(lcFiltruCript)
			*!*	modificare	ROAGEST v 2.0.55	^
			Return .T. && Daca nu au survenit erori trimite stringul la forma principala
		Endif
		
	ENDPROC

	PROCEDURE Init
		lPARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		DIMENSION this.acriterii(alen(tacriterii,1), 6)
		ACOPY(tacriterii,this.acriterii)
		DODEFAULT()
		this.lb_titlu_alb_b121.Caption="Criterii de filtrare"
		
		thisform.AddObject("SelectorCriteriu","mycrit",@tacriterii)
		*thisform.SelectorCriteriu.left=(thisform.Width-thisform.SelectorCriteriu.width)/2
		thisform.SelectorCriteriu.left=25
		thisform.SelectorCriteriu.Top=40
		
		thisform.SelectorCriteriu.visible=.T.
		thisform.SelectorCriteriu.Combo1.Setfocus
		thisform.do_colectienom()
		thisform.SelectorCriteriu.Combo1.Setfocus
		
		this.Containercriterii1.Top=this.line1.Top + 10
		currentcontainerheight= (this.Height-this.line1.Top-20)/30
		this.Containercriterii1.height=FLOOR(currentcontainerheight)*30
		
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If nKeyCode=27
			Nodefault
			This.do_renunt()
		Else
			DoDefault(nKeyCode, nShiftAltCtrl)
		Endif
		
		
	ENDPROC

	PROCEDURE paramsmatrix
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		thisform.SelectorCriteriu.Combo1.Setfocus
	ENDPROC

ENDDEFINE

DEFINE CLASS mycrit AS container 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="lbl_Logic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_OpenGroup" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_CloseGroup" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Combo1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_Add" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: loadarray
		*p: logic
		*p: negat
		*a: acriteriiuns[1,4]
		*a: acriterii[1,4]
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		BorderWidth = 0
		Height = 25
		logic = 
		Name = "mycrit"
		negat = .F.
		Width = 425
		_memberdata = <VFPData>

		</VFPData>
	*</PropValue>

	ADD OBJECT 'cmd_Add' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = "Adauga criteriu", ;
		Enabled = .F., ;
		Height = 21, ;
		Left = 327, ;
		Name = "cmd_Add", ;
		Top = 2, ;
		Visible = .F., ;
		Width = 96
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmd_CloseGroup' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = ")", ;
		Height = 21, ;
		Left = 68, ;
		Name = "cmd_CloseGroup", ;
		TabStop = .F., ;
		Top = 2, ;
		Width = 17
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmd_OpenGroup' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = "(", ;
		Height = 21, ;
		Left = 48, ;
		Name = "cmd_OpenGroup", ;
		TabStop = .F., ;
		Top = 2, ;
		Width = 17
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Combo1' AS combobox WITH ;
		DisplayCount = 8, ;
		Height = 21, ;
		Left = 99, ;
		Name = "Combo1", ;
		NumberOfElements = 8, ;
		RowSource = "", ;
		RowSourceType = 1, ;
		SpecialEffect = 1, ;
		Style = 2, ;
		Top = 1, ;
		Visible = .F., ;
		Width = 223
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'lbl_Logic' AS label WITH ;
		Alignment = 2, ;
		BackStyle = 0, ;
		Caption = "SI", ;
		FontBold = .T., ;
		FontName = "Verdana", ;
		FontSize = 10, ;
		FontUnderline = .T., ;
		ForeColor = 0,0,255, ;
		Height = 17, ;
		Left = 15, ;
		MousePointer = 15, ;
		Name = "lbl_Logic", ;
		Top = 4, ;
		Width = 33
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE Destroy
		_Screen.StatusBar.ctlMessage=""
		_Screen.StatusBar.tag=""
	ENDPROC

	PROCEDURE Init
		Lparameters tacriterii
		External Array tacriterii
		This.logic="SI"
		This.negat=.F.
		This.lbl_Logic.Caption=This.logic
		Dimension This.acriterii(Alen(tacriterii,1),7)
		Dimension This.acriteriiuns(Alen(tacriterii,1),6)
		Acopy(tacriterii,This.acriteriiuns)
		
		For x=1 To Alen(This.acriterii,1)
			For i = 1 To 6
				This.acriterii(x,i)=tacriterii(x,i)
			Endfor
			This.acriterii(x,7)=x
		Endfor
		
		nleft=110
		ntop=55
		ncontor=0
		ncontorcols=1
		nrlines=Ceiling(Alen(This.acriterii,1)/7)
		Asort(This.acriterii)
		
		For N = 1 To Alen(This.acriterii,1)
			ncontor=ncontor+1
		
			This.combo1.AddItem(This.acriterii(N,1))
		
			lbl_Criteriu="lbl_Criteriu"+Transform(N)
			This.Parent.AddObject(lbl_Criteriu,"cmd_addcriteriu")
			This.Parent.&lbl_Criteriu..Top=ntop + ncontor *17
			This.Parent.&lbl_Criteriu..Left=nleft * ncontorcols - 70
			This.Parent.&lbl_Criteriu..Caption=This.acriteriiuns(N,1)
			IF !EMPTY(This.acriteriiuns(N,6))
				This.Parent.&lbl_Criteriu..ToolTipText=This.acriteriiuns(N,6)
			ENDIF 	
			This.Parent.&lbl_Criteriu..Visible=.T.
			If ncontor=nrlines
				ncontor=0
				ncontorcols=ncontorcols+1
			Endif
		Endfor
		
		
		This.Parent.line1.Top=nrlines*17 + ntop+ 20
		This.Parent.currentHeight=10
		This.combo1.ListIndex=1
		This.cmd_Add.Enabled= .T.
		
		
	ENDPROC

	PROCEDURE loadarray
		Lparameters tacriterii
		External Array tacriterii
		This.logic="SI"
		This.negat=.F.
		This.lbl_Logic.Caption=This.logic
		Dimension This.acriterii(Alen(tacriterii,1),7)
		Acopy(tacriterii,This.acriterii)
		This.combo1.Clear
		
		
		For N = 1 To Alen(This.acriterii,1)
			lctestText=This.acriterii(N,1)
			lbExists=.F.
			For x=1 To This.Parent.nr_criterii
				ObjectName="Criteriu"+Transform(x)
				If This.Parent.Containercriterii1.&ObjectName..Tag#"GroupOpen" And This.Parent.Containercriterii1.&ObjectName..Tag#"GroupClose" And This.Parent.Containercriterii1.&ObjectName..Tag#"Sters"
					If This.Parent.Containercriterii1.&ObjectName..numecriteriu=lctestText
						lbExists=.T.
					Endif
				Endif
			Endfor
			If lbExists And (This.acriterii(N,3)="E" Or This.acriterii(N,3)="A")
				This.combo1.AddItem("\]"+This.acriterii(N,1),N,1)
			Else
				This.combo1.AddItem(This.acriterii(N,1),N,1)
			Endif
		
		
		Endfor
		This.cmd_Add.Enabled= .T.
		
	ENDPROC

	PROCEDURE cmd_Add.Click
		*!* Adauga criteriu pe container
		lctextoptions="incepe cu,este,nu este,contine,nu contine,nu are valori,are valori"
		lcnroptions="egal,diferit,mai mare sau egal,mai mic sau egal,mai mare,mai mic"
		lcdataoptions="egala,diferita,mai mare,mai mica,mai mare sau egala,mai mica sau egala"
		lctext=""
		lcClassId=""
		lnoftimes=1
		IF SUBSTR(THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX),1,1)#"\"
			LOCAL lcTipCriteriu
			lcTipCriteriu = THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),3)
			IF AT('|', lcTipCriteriu) > 0
				lcTipCriteriu = LEFT(lcTipCriteriu, AT('|', lcTipCriteriu) -1) && tipul criteriului N|GetMask(12,gnPA)
			ENDIF 	
		
			DO WHILE lnoftimes < 3
				DO CASE
					CASE INLIST(lcTipCriteriu, "N", "D1")
						lcOptions = lcnroptions
					CASE lcTipCriteriu = "T"
						lcOptions=lctextoptions
					CASE lcTipCriteriu = "I"
						lcOptions="Doarlista"
					CASE lcTipCriteriu = "D"
						lcOptions=lcdataoptions
					CASE lcTipCriteriu = "E"
						lcOptions="Disabled"
					CASE lcTipCriteriu = "A"
						lcOptions = SUBSTR(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4),1,AT("#",THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4))-1)
						lctext = SUBSTR(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4),AT("#",THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4))+1)
						IF(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),2))#"nofield"
							lcClassId = THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),2)
						ENDIF
					OTHERWISE
						lcOptions = lctextoptions
				ENDCASE
		
				IF THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)#"" AND THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)#"none"
					lcKeyNomenclator=THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)
					lcIdCamp=THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4)
				ELSE
					lcKeyNomenclator="none"
					lcIdCamp=""
				ENDIF
		
		
				THIS.PARENT.PARENT.nr_criterii=THIS.PARENT.PARENT.nr_criterii+1
				NrCriterii=THIS.PARENT.PARENT.nr_criterii
				ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
				PreviusObjectName="Criteriu"+TRANSFORM(NrCriterii-1)
				IF(NrCriterii=1 OR THIS.PARENT.PARENT.Containercriterii1.&PreviusObjectName..TAG="GroupOpen")
					logicCaption=""
				ELSE
					*** in caz ca sunt sterse primele inregistrari
					lbexinreg=.F.
					FOR i = 1 TO NrCriterii-1
						locurObj="Criteriu"+TRANSFORM(i)
						IF THIS.PARENT.PARENT.Containercriterii1.&locurObj..TAG#"Sters"
							lbexinreg=.T.
						ENDIF
					ENDFOR
					***
					IF lbexinreg=.T.
						logicCaption=THIS.PARENT.logic
					ELSE
						logicCaption=""
					ENDIF
				ENDIF
		
				WITH THIS.PARENT.PARENT
					.Containercriterii1.ADDOBJECT("&ObjectName","_ccriteriu",THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX),logicCaption,lcOptions,lcKeyNomenclator,THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),3))
					IF lcIdCamp#""
						.Containercriterii1.&ObjectName..idCamp=lcIdCamp
					ENDIF
					.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..HEIGHT+10
					.Containercriterii1.&ObjectName..LEFT=.currentLeft
					.Containercriterii1.&ObjectName..criteriu_nr=THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6)
					lcthiscrit="lbl_Criteriu"+TRANSFORM(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6))
					THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(15,15,200)
		
					*!* setare Mai mare sau egal / Mai mic sau egal in functie de ce e selectat
					IF lcTipCriteriu = "D"
						IF lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(5)
						ELSE
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(6)
						ENDIF
					ENDIF
					IF INLIST(lcTipCriteriu, "N", "D1")
						IF lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(3)
						ELSE
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(4)
						ENDIF
					ENDIF
					*!* sfarsit setare Mai mare sau egal / Mai mic sau egal in functie de ce e selectat
		
		
					lcspecial="false"
					IF lctext#""
						.Containercriterii1.&ObjectName..text1.VALUE=lctext
						.Containercriterii1.&ObjectName..codcriteriu=SUBSTR(lctext,1,AT(",",lctext)-1)
						.Containercriterii1.&ObjectName..text1.VISIBLE=.F.
						.Containercriterii1.&ObjectName..ClassId=lcClassId
						.Containercriterii1.&ObjectName..combo1.WIDTH=275
						THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)="\]"+THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)
		
						IF(THIS.PARENT.combo1.LISTINDEX<THIS.PARENT.combo1.LISTCOUNT-1)
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX+1
						ELSE
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX-1
						ENDIF
		
						lcspecial="true"
						THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(154,154,154)
						THIS.PARENT.PARENT.&lcthiscrit..stare="inactiv"
						THIS.PARENT.PARENT.&lcthiscrit..MOUSEPOINTER= 0
					ENDIF
		
					IF lcTipCriteriu = "E"
						THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)="\]"+THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)
						IF(THIS.PARENT.combo1.LISTINDEX<THIS.PARENT.combo1.LISTCOUNT-1)
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX+1
						ELSE
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX-1
						ENDIF
						lcspecial="true"
						THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(154,154,154)
						THIS.PARENT.PARENT.&lcthiscrit..stare="inactiv"
						THIS.PARENT.PARENT.&lcthiscrit..MOUSEPOINTER= 0
					ENDIF
		
					IF lcTipCriteriu = "I" AND .Containercriterii1.&ObjectName..idValue=""
						.Containercriterii1.&ObjectName..deleteobj()
					ENDIF
		
		
					.Containercriterii1.&ObjectName..VISIBLE=.T.
					.REFRESH()
					.Containercriterii1.&ObjectName..VISIBLE=.T.
					.REFRESH()
				ENDWITH
		
				IF lnoftimes=1
					lcoldobj=ObjectName
					templogic =THIS.PARENT.logic
					IF INLIST(lcTipCriteriu, "N", "D") AND lcspecial="false"
						THIS.PARENT.logic="SI"
						THIS.PARENT.lbl_logic.CAPTION="SI"
					ELSE
						THIS.PARENT.logic=templogic
						THIS.PARENT.lbl_logic.CAPTION=templogic
						lnoftimes=3
					ENDIF
				ELSE
					THIS.PARENT.logic=templogic
					THIS.PARENT.lbl_logic.CAPTION=templogic
					lnoftimes=3
				ENDIF
				lnoftimes=lnoftimes+1
			ENDDO
			THIS.PARENT.PARENT.Containercriterii1.&lcoldobj..text1.SETFOCUS()
			THIS.PARENT.PARENT.Containercriterii1.do_refresh()
			THIS.PARENT.PARENT.Containercriterii1.scroll_bottom()
		ENDIF
		
	ENDPROC

	PROCEDURE cmd_CloseGroup.Click
		this.Parent.Parent.nr_criterii=this.Parent.Parent.nr_criterii+1
		NrCriterii=this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
		PreviusObjectName="Criteriu"+transform(NrCriterii-1)
		
		WITH this.Parent.Parent
		IF .currentleft#10
			.Containercriterii1.AddObject("&ObjectName","paranteza")
			.Containercriterii1.&ObjectName..AddProperty("logic","")
			.Containercriterii1.&ObjectName..Caption=" )"
			.Containercriterii1.&ObjectName..tag="GroupClose"
			.Containercriterii1.&ObjectName..top=.currentHeight- .Containercriterii1.offset
			.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..height+10
			.currentLeft=.currentLeft-25
			.Containercriterii1.&ObjectName..left=.currentLeft
			.Containercriterii1.&ObjectName..backstyle=0
			.Containercriterii1.&ObjectName..Visible=.T.
			.Containercriterii1.&ObjectName..Caption=" )"
			.Containercriterii1.&ObjectName..tag="GroupClose"
			.Containercriterii1.do_refresh()
			.Containercriterii1.scroll_bottom()
			.Refresh()
			ELSE
			this.Parent.Parent.nr_criterii=NrCriterii-1
		ENDIF
		ENDWITH
		
	ENDPROC

	PROCEDURE cmd_OpenGroup.Click
		this.Parent.Parent.nr_criterii=this.Parent.Parent.nr_criterii+1
		NrCriterii=this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
		PreviusObjectName="Criteriu"+transform(NrCriterii-1)
		if(NrCriterii=1 or this.Parent.Parent.Containercriterii1.&PreviusObjectName..tag="GroupOpen")
		logicCaption=""
		ELSE
		logicCaption=this.Parent.logic
		ENDIF
		
		WITH this.Parent.Parent
			.Containercriterii1.AddObject("&ObjectName","paranteza")
			.Containercriterii1.&ObjectName..AddProperty("logic",logicCaption)
			.Containercriterii1.&ObjectName..Caption=logicCaption+" ("
			.Containercriterii1.&ObjectName..tag="GroupOpen"
			.Containercriterii1.&ObjectName..top=.currentHeight- .Containercriterii1.offset
			.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..height+10 
			.Containercriterii1.&ObjectName..left=.currentLeft
			.currentLeft=.currentLeft+25
			.Containercriterii1.&ObjectName..backstyle=0
			.Containercriterii1.&ObjectName..Visible=.T.
		
			.Containercriterii1.&ObjectName..Caption=logicCaption+" ("
			.Containercriterii1.&ObjectName..tag="GroupOpen"
			.Containercriterii1.do_refresh()
			.Containercriterii1.scroll_bottom()
			.Refresh()
		ENDWITH
		
		
		
		
		
		
	ENDPROC

	PROCEDURE Combo1.InteractiveChange
		this.Parent.cmd_Add.Enabled= .T.
		
	ENDPROC

	PROCEDURE Combo1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		IF nkeycode=13
		this.Parent.cmd_Add.SetFocus
		DODEFAULT()
		
		
		ENDIF
		
	ENDPROC

	PROCEDURE lbl_Logic.Click
		IF this.Parent.logic="SI"
			this.Parent.logic="SAU"
		ELSE
			this.Parent.logic="SI"
		ENDIF
		this.Caption=this.Parent.logic
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS mycrit_vechi AS container 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Combo1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_Logic" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_Add" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_OpenGroup" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmd_CloseGroup" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: loadarray
		*p: logic
		*p: negat
		*a: acriteriiuns[1,4]
		*a: acriterii[1,4]
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		BorderWidth = 0
		Height = 21
		logic = 
		Name = "mycrit"
		negat = .F.
		Width = 425
	*</PropValue>

	ADD OBJECT 'cmd_Add' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = "Adauga criteriu", ;
		Enabled = .F., ;
		Height = 21, ;
		Left = 282, ;
		Name = "cmd_Add", ;
		Top = 1, ;
		Width = 96
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmd_CloseGroup' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = ")", ;
		Height = 21, ;
		Left = 401, ;
		Name = "cmd_CloseGroup", ;
		Top = 1, ;
		Width = 17
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmd_OpenGroup' AS commandbutton WITH ;
		BackColor = 255,255,255, ;
		Caption = "(", ;
		Height = 21, ;
		Left = 381, ;
		Name = "cmd_OpenGroup", ;
		Top = 1, ;
		Width = 17
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Combo1' AS combobox WITH ;
		DisplayCount = 8, ;
		Height = 21, ;
		Left = 54, ;
		Name = "Combo1", ;
		NumberOfElements = 8, ;
		RowSource = "", ;
		RowSourceType = 1, ;
		SpecialEffect = 1, ;
		Style = 2, ;
		Top = 0, ;
		Width = 223
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'lbl_Logic' AS label WITH ;
		Alignment = 2, ;
		BackStyle = 0, ;
		Caption = "SI", ;
		FontBold = .T., ;
		FontName = "Verdana", ;
		FontSize = 10, ;
		FontUnderline = .T., ;
		ForeColor = 0,0,255, ;
		Height = 17, ;
		Left = 15, ;
		MousePointer = 15, ;
		Name = "lbl_Logic", ;
		Top = 4, ;
		Width = 33
		*< END OBJECT: BaseClass="label" />
	
	PROCEDURE Destroy
		_Screen.StatusBar.ctlMessage=""
		_Screen.StatusBar.tag=""
	ENDPROC

	PROCEDURE Init
		LPARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		this.logic="SI"
		this.negat=.F.
		this.lbl_Logic.caption=this.logic 
		DIMENSION this.acriterii(ALEN(tacriterii,1),6)
		DIMENSION this.acriteriiuns(ALEN(tacriterii,1),5)
		ACOPY(tacriterii,this.acriteriiuns)
		
		FOR x=1 TO ALEN(this.acriterii,1)
		FOR i = 1 TO 5 
			this.acriterii(x,i)=tacriterii(x,i)
		ENDFOR
			this.acriterii(x,6)=x
		ENDFOR
		
		nleft=110
		ntop=55
		ncontor=0
		ncontorcols=1
		nrlines=Ceiling(ALEN(this.acriterii,1)/7)
		ASORT(this.acriterii)
		
		FOR n = 1 TO ALEN(this.acriterii,1)
		ncontor=ncontor+1
		
		this.combo1.AddItem(this.acriterii(n,1))
		
		lbl_Criteriu="lbl_Criteriu"+TRANSFORM(n)
		this.Parent.AddObject(lbl_Criteriu,"cmd_addcriteriu")
		this.Parent.&lbl_Criteriu..top=ntop + nContor *17
		this.Parent.&lbl_Criteriu..left=nleft * nContorcols - 70
		this.Parent.&lbl_Criteriu..caption=this.acriteriiuns(n,1)
		this.Parent.&lbl_Criteriu..visible=.T.
		IF ncontor=nrlines
		ncontor=0
		ncontorcols=ncontorcols+1
		ENDIF
		ENDFOR
		
		
		this.Parent.line1.top=nrlines*17 + ntop+ 20
		this.Parent.currentHeight=10
		this.combo1.ListIndex=1
		this.cmd_Add.Enabled= .T.
		
		
	ENDPROC

	PROCEDURE loadarray
		LPARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		this.logic="SI"
		this.negat=.F.
		this.lbl_Logic.caption=this.logic 
		DIMENSION this.acriterii(ALEN(tacriterii,1),6)
		ACOPY(tacriterii,this.acriterii)
		this.combo1.Clear
		
		
		FOR n = 1 TO ALEN(this.acriterii,1)
		lctestText=this.acriterii(n,1)
		lbExists=.F.
		FOR x=1 TO this.Parent.nr_criterii
		ObjectName="Criteriu"+Transform(x)
			IF this.Parent.Containercriterii1.&ObjectName..Tag#"GroupOpen" AND this.Parent.Containercriterii1.&ObjectName..Tag#"GroupClose" AND this.Parent.Containercriterii1.&ObjectName..Tag#"Sters"
				IF this.Parent.Containercriterii1.&ObjectName..numecriteriu=lctestText
					lbExists=.T.
				ENDIF
			ENDIF
		ENDFOR
		IF lbExists AND (this.acriterii(n,3)="E" OR this.acriterii(n,3)="A")
		this.combo1.AddItem("\]"+this.acriterii(n,1),n,1)
		ELSE
		this.combo1.AddItem(this.acriterii(n,1),n,1)
		ENDIF
		
			
		ENDFOR
		this.cmd_Add.Enabled= .T.
		
	ENDPROC

	PROCEDURE cmd_Add.Click
		*!* Adauga criteriu pe container
		lctextoptions="incepe cu,este,nu este,contine,nu contine,nu are valori,are valori"
		lcnroptions="egal,diferit,mai mare sau egal,mai mic sau egal,mai mare,mai mic"
		lcdataoptions="egala,diferita,mai mare,mai mica,mai mare sau egala,mai mica sau egala"
		lctext=""
		lcClassId=""
		lnoftimes=1
		IF SUBSTR(THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX),1,1)#"\"
			LOCAL lcTipCriteriu
			lcTipCriteriu = THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),3)
			IF AT('|', lcTipCriteriu) > 0
				lcTipCriteriu = LEFT(lcTipCriteriu, AT('|', lcTipCriteriu) -1) && tipul criteriului N|GetMask(12,gnPA)
			ENDIF 	
		
			DO WHILE lnoftimes < 3
				DO CASE
					CASE INLIST(lcTipCriteriu, "N", "D1")
						lcOptions = lcnroptions
					CASE lcTipCriteriu = "T"
						lcOptions=lctextoptions
					CASE lcTipCriteriu = "I"
						lcOptions="Doarlista"
					CASE lcTipCriteriu = "D"
						lcOptions=lcdataoptions
					CASE lcTipCriteriu = "E"
						lcOptions="Disabled"
					CASE lcTipCriteriu = "A"
						lcOptions = SUBSTR(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4),1,AT("#",THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4))-1)
						lctext = SUBSTR(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4),AT("#",THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4))+1)
						IF(THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),2))#"nofield"
							lcClassId = THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),2)
						ENDIF
					OTHERWISE
						lcOptions = lctextoptions
				ENDCASE
		
				IF THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)#"" AND THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)#"none"
					lcKeyNomenclator=THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),5)
					lcIdCamp=THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),4)
				ELSE
					lcKeyNomenclator="none"
					lcIdCamp=""
				ENDIF
		
		
				THIS.PARENT.PARENT.nr_criterii=THIS.PARENT.PARENT.nr_criterii+1
				NrCriterii=THIS.PARENT.PARENT.nr_criterii
				ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
				PreviusObjectName="Criteriu"+TRANSFORM(NrCriterii-1)
				IF(NrCriterii=1 OR THIS.PARENT.PARENT.Containercriterii1.&PreviusObjectName..TAG="GroupOpen")
					logicCaption=""
				ELSE
					*** in caz ca sunt sterse primele inregistrari
					lbexinreg=.F.
					FOR i = 1 TO NrCriterii-1
						locurObj="Criteriu"+TRANSFORM(i)
						IF THIS.PARENT.PARENT.Containercriterii1.&locurObj..TAG#"Sters"
							lbexinreg=.T.
						ENDIF
					ENDFOR
					***
					IF lbexinreg=.T.
						logicCaption=THIS.PARENT.logic
					ELSE
						logicCaption=""
					ENDIF
				ENDIF
		
				WITH THIS.PARENT.PARENT
					.Containercriterii1.ADDOBJECT("&ObjectName","_ccriteriu",THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX),logicCaption,lcOptions,lcKeyNomenclator,THIS.PARENT.acriteriiuns(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6),3))
					IF lcIdCamp#""
						.Containercriterii1.&ObjectName..idCamp=lcIdCamp
					ENDIF
					.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..HEIGHT+10
					.Containercriterii1.&ObjectName..LEFT=.currentLeft
					.Containercriterii1.&ObjectName..criteriu_nr=THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6)
					lcthiscrit="lbl_Criteriu"+TRANSFORM(THIS.PARENT.acriterii(THIS.PARENT.combo1.LISTINDEX,6))
					THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(15,15,200)
		
					*!* setare Mai mare sau egal / Mai mic sau egal in functie de ce e selectat
					IF lcTipCriteriu = "D"
						IF lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(5)
						ELSE
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(6)
						ENDIF
					ENDIF
					IF INLIST(lcTipCriteriu, "N", "D1")
						IF lnoftimes=1
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(3)
						ELSE
							.Containercriterii1.&ObjectName..combo1.VALUE=.Containercriterii1.&ObjectName..combo1.LIST(4)
						ENDIF
					ENDIF
					*!* sfarsit setare Mai mare sau egal / Mai mic sau egal in functie de ce e selectat
		
		
					lcspecial="false"
					IF lctext#""
						.Containercriterii1.&ObjectName..text1.VALUE=lctext
						.Containercriterii1.&ObjectName..codcriteriu=SUBSTR(lctext,1,AT(",",lctext)-1)
						.Containercriterii1.&ObjectName..text1.VISIBLE=.F.
						.Containercriterii1.&ObjectName..ClassId=lcClassId
						.Containercriterii1.&ObjectName..combo1.WIDTH=275
						THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)="\]"+THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)
		
						IF(THIS.PARENT.combo1.LISTINDEX<THIS.PARENT.combo1.LISTCOUNT-1)
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX+1
						ELSE
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX-1
						ENDIF
		
						lcspecial="true"
						THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(154,154,154)
						THIS.PARENT.PARENT.&lcthiscrit..stare="inactiv"
						THIS.PARENT.PARENT.&lcthiscrit..MOUSEPOINTER= 0
					ENDIF
		
					IF lcTipCriteriu = "E"
						THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)="\]"+THIS.PARENT.combo1.LIST(THIS.PARENT.combo1.LISTINDEX)
						IF(THIS.PARENT.combo1.LISTINDEX<THIS.PARENT.combo1.LISTCOUNT-1)
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX+1
						ELSE
							THIS.PARENT.combo1.LISTINDEX=THIS.PARENT.combo1.LISTINDEX-1
						ENDIF
						lcspecial="true"
						THIS.PARENT.PARENT.&lcthiscrit..FORECOLOR=RGB(154,154,154)
						THIS.PARENT.PARENT.&lcthiscrit..stare="inactiv"
						THIS.PARENT.PARENT.&lcthiscrit..MOUSEPOINTER= 0
					ENDIF
		
					IF lcTipCriteriu = "I" AND .Containercriterii1.&ObjectName..idValue=""
						.Containercriterii1.&ObjectName..deleteobj()
					ENDIF
		
		
					.Containercriterii1.&ObjectName..VISIBLE=.T.
					.REFRESH()
					.Containercriterii1.&ObjectName..VISIBLE=.T.
					.REFRESH()
				ENDWITH
		
				IF lnoftimes=1
					lcoldobj=ObjectName
					templogic =THIS.PARENT.logic
					IF INLIST(lcTipCriteriu, "N", "D") AND lcspecial="false"
						THIS.PARENT.logic="SI"
						THIS.PARENT.lbl_logic.CAPTION="SI"
					ELSE
						THIS.PARENT.logic=templogic
						THIS.PARENT.lbl_logic.CAPTION=templogic
						lnoftimes=3
					ENDIF
				ELSE
					THIS.PARENT.logic=templogic
					THIS.PARENT.lbl_logic.CAPTION=templogic
					lnoftimes=3
				ENDIF
				lnoftimes=lnoftimes+1
			ENDDO
			THIS.PARENT.PARENT.Containercriterii1.&lcoldobj..text1.SETFOCUS()
			THIS.PARENT.PARENT.Containercriterii1.do_refresh()
			THIS.PARENT.PARENT.Containercriterii1.scroll_bottom()
		ENDIF
		
	ENDPROC

	PROCEDURE cmd_CloseGroup.Click
		this.Parent.Parent.nr_criterii=this.Parent.Parent.nr_criterii+1
		NrCriterii=this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
		PreviusObjectName="Criteriu"+transform(NrCriterii-1)
		
		WITH this.Parent.Parent
		IF .currentleft#10
			.Containercriterii1.AddObject("&ObjectName","paranteza")
			.Containercriterii1.&ObjectName..AddProperty("logic","")
			.Containercriterii1.&ObjectName..Caption=" )"
			.Containercriterii1.&ObjectName..tag="GroupClose"
			.Containercriterii1.&ObjectName..top=.currentHeight- .Containercriterii1.offset
			.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..height+10
			.currentLeft=.currentLeft-25
			.Containercriterii1.&ObjectName..left=.currentLeft
			.Containercriterii1.&ObjectName..backstyle=0
			.Containercriterii1.&ObjectName..Visible=.T.
			.Containercriterii1.&ObjectName..Caption=" )"
			.Containercriterii1.&ObjectName..tag="GroupClose"
			.Containercriterii1.do_refresh()
			.Containercriterii1.scroll_bottom()
			.Refresh()
			ELSE
			this.Parent.Parent.nr_criterii=NrCriterii-1
		ENDIF
		ENDWITH
		
	ENDPROC

	PROCEDURE cmd_OpenGroup.Click
		this.Parent.Parent.nr_criterii=this.Parent.Parent.nr_criterii+1
		NrCriterii=this.Parent.Parent.nr_criterii
		ObjectName="Criteriu"+TRANSFORM(NrCriterii)
		
		PreviusObjectName="Criteriu"+transform(NrCriterii-1)
		if(NrCriterii=1 or this.Parent.Parent.Containercriterii1.&PreviusObjectName..tag="GroupOpen")
		logicCaption=""
		ELSE
		logicCaption=this.Parent.logic
		ENDIF
		
		WITH this.Parent.Parent
			.Containercriterii1.AddObject("&ObjectName","paranteza")
			.Containercriterii1.&ObjectName..AddProperty("logic",logicCaption)
			.Containercriterii1.&ObjectName..Caption=logicCaption+" ("
			.Containercriterii1.&ObjectName..tag="GroupOpen"
			.Containercriterii1.&ObjectName..top=.currentHeight- .Containercriterii1.offset
			.currentHeight=.currentHeight+.Containercriterii1.&ObjectName..height+10 
			.Containercriterii1.&ObjectName..left=.currentLeft
			.currentLeft=.currentLeft+25
			.Containercriterii1.&ObjectName..backstyle=0
			.Containercriterii1.&ObjectName..Visible=.T.
		
			.Containercriterii1.&ObjectName..Caption=logicCaption+" ("
			.Containercriterii1.&ObjectName..tag="GroupOpen"
			.Containercriterii1.do_refresh()
			.Containercriterii1.scroll_bottom()
			.Refresh()
		ENDWITH
		
		
		
		
		
		
	ENDPROC

	PROCEDURE Combo1.InteractiveChange
		this.Parent.cmd_Add.Enabled= .T.
		
	ENDPROC

	PROCEDURE Combo1.KeyPress
		LPARAMETERS nKeyCode, nShiftAltCtrl
		IF nkeycode=13
		this.Parent.cmd_Add.SetFocus
		DODEFAULT()
		
		
		ENDIF
		
	ENDPROC

	PROCEDURE lbl_Logic.Click
		IF this.Parent.logic="SI"
			this.Parent.logic="SAU"
		ELSE
			this.Parent.logic="SI"
		ENDIF
		this.Caption=this.Parent.logic
		
		
	ENDPROC

ENDDEFINE

DEFINE CLASS paranteza AS label 
 	*< CLASSDATA: Baseclass="label" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<DefinedPropArrayMethod>
		*p: codcriteriu
		*p: _memberdata		&& XML Metadata for customizable properties
	*</DefinedPropArrayMethod>

	*<PropValue>
		Caption = "Label1"
		codcriteriu = 
		Height = 20
		MousePointer = 15
		Name = "paranteza"
		Width = 68
		_memberdata = <VFPData>

		</VFPData>
	*</PropValue>
	
	PROCEDURE Click
		CurrentObjectNumber=VAL(ALLTRIM(SUBSTR(THIS.NAME,9)))
		lnDeletedHeight =THIS.HEIGHT + 10
		THIS.PARENT.PARENT.CurrentHeight=THIS.PARENT.PARENT.CurrentHeight - lnDeletedHeight
		THIS.HEIGHT=0
		
		DO CASE
			CASE THIS.TAG="GroupClose"
				THIS.TAG="Sters"
				THIS.PARENT.PARENT.currentLeft=THIS.PARENT.PARENT.currentLeft+25
			CASE THIS.TAG="GroupOpen" AND THIS.PARENT.PARENT.currentLeft > 25
				THIS.TAG="Sters"
				THIS.PARENT.PARENT.currentLeft = THIS.PARENT.PARENT.currentLeft-25
			OTHERWISE
				THIS.TAG="Sters"
		ENDCASE
		
		FOR N=CurrentObjectNumber TO THIS.PARENT.PARENT.nr_criterii
			ObjectName="Criteriu"+TRANSFORM(N)
			THIS.PARENT.&ObjectName..TOP=THIS.PARENT.&ObjectName..TOP-lnDeletedHeight
		ENDFOR
		
		
		
		
	ENDPROC

	PROCEDURE MouseEnter
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ForeColor=RGB(0,0,255)
		this.FontBold=.T.
		
		
	ENDPROC

	PROCEDURE MouseLeave
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ForeColor=RGB(0,0,0)
		this.FontBold=.F.
		
	ENDPROC

ENDDEFINE

DEFINE CLASS scontainer AS container 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="up_1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="down_1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_refresh
		*m: do_scrolldown
		*m: do_scrollup
		*m: scroll_bottom
		*p: aaaaaaa
		*p: offset
		*p: pic
	*</DefinedPropArrayMethod>

	*<PropValue>
		aaaaaaa = 
		BackStyle = 0
		BorderWidth = 0
		Height = 330
		Name = "scontainer"
		offset = 0
		pic = .F.
		Picture = 
		Width = 817
	*</PropValue>

	ADD OBJECT 'down_1' AS but_jos WITH ;
		Left = 780, ;
		Name = "down_1", ;
		Top = 43
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'up_1' AS but_sus WITH ;
		Left = 780, ;
		Name = "up_1", ;
		Top = 13
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />
	
	PROCEDURE do_refresh
		LOCAL lnNr
		lnheight=10
		For Each Item In This.Controls
			If Item.Name#"up_1" And  Item.Name#"down_1" And Item.Tag#"Sters" And Item.Top>0
				lnheight=lnheight+Item.Height+10
			Endif
		Endfor
		If lnheight> This.Height
			This.down_1.Tag="activ"
			This.down_1.Visible=.T.
		Else
			This.down_1.Tag="inactiv"
			This.down_1.Visible=.F.
		Endif
		lnNr=0
		goodobjectname="none"
		DO WHILE lnNr<this.Parent.nr_criterii
		lnNr=lnNr+1
		objectname="Criteriu"+TRANSFORM(lnNr)
			IF Pemstatus(This,"&objectname",5)
				IF this.&objectname..Tag#"Sters"
					goodobjectname=objectname
					EXIT
				ENDIF
			ENDIF
		ENDDO
		
		
		If Pemstatus(This,goodobjectname,5)
			If This.&goodobjectname..Top<0
				This.up_1.Tag="activ"
				This.up_1.Visible=.T.
			Else
				This.up_1.Tag="inactiv"
				This.up_1.Visible=.F.
			Endif
		Else
			This.up_1.Tag="inactiv"
			This.up_1.Visible=.F.
		Endif
		
		
		
	ENDPROC

	PROCEDURE do_scrolldown
		IF this.down_1.Tag="activ"
		FOR EACH item IN this.controls
		IF item.name#"up_1" AND item.name#"down_1"
		item.top=item.top-30
		ENDIF
		ENDFOR
		this.offset=this.offset+30
		this.do_refresh()
		ENDIF
	ENDPROC

	PROCEDURE do_scrollup
		IF this.up_1.Tag="activ"
		FOR EACH item IN this.controls
		IF item.name#"up_1" AND  item.name#"down_1"
		item.top=item.top+30
		ENDIF
		ENDFOR
		this.offset=this.offset-30
		this.do_refresh()
		ENDIF
		
	ENDPROC

	PROCEDURE Init
		this.do_refresh
		
	ENDPROC

	PROCEDURE scroll_bottom
		DO WHILE this.down_1.Tag="activ"
		this.do_scrolldown
		ENDDO
		
		
		
	ENDPROC

ENDDEFINE
