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

	*<DefinedPropArrayMethod>
		*p: camp_nume
		*p: criteriu1
		*p: criteriu2
		*p: filtru
		*p: mask
		*p: nrzec
		*p: tip
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		Caption = "Check1"
		criteriu1 = 1
		criteriu2 = 2
		filtru = 
		Height = 17
		mask = 
		Name = "ck_filtru_numar"
		nrzec = 0
		tip = N
		Width = 60
	*</PropValue>
	
	PROCEDURE InteractiveChange
		WITH this
			.filtru = ""
			IF .Value = 0
				RETURN 
			ENDIF 
			IF TYPE('.mask') = 'N'
				.mask = ALLTRIM(STR(.mask))
			ENDIF 	
		
			DO FORM frm_filtru_numar WITH .camp_nume, .caption, .criteriu1, .criteriu2, .tip, .mask, .nrzec TO .filtru
			IF .filtru = ""
				.Value = 0
			ENDIF 
			
		ENDWITH 
	ENDPROC

	PROCEDURE Valid
		LOCAL ARRAY laSearch[1]
		
		AMEMBERS(laSearch,this.Parent,1,'G')
		IF ASCAN(laSearch,'AFISACTUAL')#0
			this.Parent.afisactual
		ENDIF 
		RELEASE laSearch 	
		
	ENDPROC

ENDDEFINE

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

	*<DefinedPropArrayMethod>
		*p: camp_nume
		*p: cintre
		*p: criteriu
		*p: criteriu2
		*p: cvaloare1
		*p: cvaloare2
		*p: filtru
	*</DefinedPropArrayMethod>

	*<PropValue>
		Alignment = 0
		BackStyle = 0
		camp_nume = 
		Caption = "Check1"
		cintre = 
		criteriu = 1
		criteriu2 = 1
		cvaloare1 = 
		cvaloare2 = 
		filtru = 
		Height = 17
		Name = "ck_filtru_text"
		Width = 60
	*</PropValue>
	
	PROCEDURE InteractiveChange
		WITH this
			.filtru = ""
			IF .Value = 0
				RETURN 
			ENDIF 
		
			PRIVATE pcValoare1, pcValoare2, pcIntre, pnCriteriu, pnCriteriu2 && variabile pe care le completeaza forma frm_filtru_text
			pcValoare1 = .cValoare1
			pcValoare2 = .cValoare2	
			pnCriteriu = .criteriu
			pnCriteriu2 = .criteriu2
			pcIntre = .cIntre
			
		
			
			DO FORM frm_filtru_text WITH .camp_nume,.caption,.criteriu,.criteriu2 TO .filtru
			
			IF .filtru = ""
				.Value = 0
				.cValoare1 = ""
				.cValoare2 = ""	
				.criteriu = 1
				.criteriu2 = 1
				.cIntre = ""
			ELSE
				.cValoare1 = pcValoare1
				.cValoare2 = pcValoare2				
				.criteriu = pnCriteriu
				.criteriu2 = pnCriteriu2
				.cIntre = pcIntre
			ENDIF 
		ENDWITH 
	ENDPROC

	PROCEDURE Valid
		LOCAL ARRAY laSearch[1]
		
		AMEMBERS(laSearch,this.Parent,1,'G')
		IF ASCAN(laSearch,'AFISACTUAL')#0
			this.Parent.afisactual
		ENDIF 
		RELEASE laSearch 	
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_filtru_text AS formtermin 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="Criteriu" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Optiongroup1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Criteriu2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Text2" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: camp_nume
		*p: filtru
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		DoCreate = .T.
		filtru = 
		Height = 111
		lhide = .F.
		Name = "frm_filtru_text"
		ScrollBars = 0
		Width = 312
		_shape1.Name = "_shape1"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 5
		BUT_TERMIN1.Left = 282
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 2
		BUT_TERMIN1.Top = 1
		Resizer1.Label1.Name = "Label1"
		Resizer1.Name = "Resizer1"
		Resizer1.TabIndex = 7
	*</PropValue>

	ADD OBJECT 'Criteriu' AS combobox WITH ;
		BorderStyle = 0, ;
		BoundColumn = 2, ;
		BoundTo = .T., ;
		ColumnCount = 2, ;
		ColumnLines = .F., ;
		ColumnWidths = "72,0", ;
		FontItalic = .T., ;
		Height = 24, ;
		Left = 11, ;
		Name = "Criteriu", ;
		ReadOnly = .F., ;
		RowSource = "incepe cu...,1,este...,2,nu este...,3,contine...,4,nu contine...,5", ;
		RowSourceType = 1, ;
		SpecialEffect = 2, ;
		Style = 2, ;
		TabIndex = 3, ;
		ToolTipText = "Selectati criteriul de comparare", ;
		Top = 62, ;
		Width = 100
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Criteriu2' AS combobox WITH ;
		BorderStyle = 0, ;
		BoundColumn = 2, ;
		BoundTo = .T., ;
		ColumnCount = 2, ;
		ColumnLines = .F., ;
		ColumnWidths = "72,0", ;
		FontItalic = .T., ;
		Height = 24, ;
		Left = 11, ;
		Name = "Criteriu2", ;
		ReadOnly = .F., ;
		RowSource = "incepe cu...,1,este...,2,nu este...,3,contine...,4,nu contine...,5", ;
		RowSourceType = 1, ;
		SpecialEffect = 2, ;
		Style = 2, ;
		TabIndex = 8, ;
		ToolTipText = "Selectati criteriul de comparare", ;
		Top = 120, ;
		Width = 100
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Optiongroup1' AS optiongroup WITH ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 3, ;
		Height = 18, ;
		Left = 94, ;
		Name = "Optiongroup1", ;
		TabIndex = 4, ;
		Top = 90, ;
		Value = 3, ;
		Width = 193, ;
		Option1.AutoSize = .F., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "si", ;
		Option1.FontItalic = .T., ;
		Option1.Height = 17, ;
		Option1.Left = 66, ;
		Option1.Name = "Option1", ;
		Option1.Top = 2, ;
		Option1.Value = 0, ;
		Option1.Width = 58, ;
		Option2.BackStyle = 0, ;
		Option2.Caption = "sau", ;
		Option2.FontItalic = .T., ;
		Option2.Height = 17, ;
		Option2.Left = 134, ;
		Option2.Name = "Option2", ;
		Option2.Top = 2, ;
		Option2.Width = 54, ;
		Option3.BackStyle = 0, ;
		Option3.Caption = "", ;
		Option3.ForeColor = 128,128,128, ;
		Option3.Height = 17, ;
		Option3.Left = 5, ;
		Option3.Name = "Option3", ;
		Option3.Style = 0, ;
		Option3.Top = 2, ;
		Option3.Value = 1, ;
		Option3.Width = 43
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Text' AS textbox WITH ;
		Format = "!KT", ;
		Height = 25, ;
		Left = 110, ;
		Name = "Text", ;
		TabIndex = 1, ;
		ToolTipText = "", ;
		Top = 62, ;
		Width = 198
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Text2' AS textbox WITH ;
		Format = "!KT", ;
		Height = 25, ;
		Left = 110, ;
		Name = "Text2", ;
		TabIndex = 6, ;
		ToolTipText = "", ;
		Top = 120, ;
		Width = 198
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Destroy
		Do Case
			Case Thisform.opTIONGROUP1.Value = 1
				lcIntre = [ AND ]
			Case Thisform.opTIONGROUP1.Value = 2
				lcIntre = [ OR ]
			Otherwise
				lcIntre = ''
		Endcase
		
		If Type("pcIntre") = "C" && variabila privata folosita in ck_filtru_text pt a initializa proprietatea cIntre
			pcIntre = lcIntre
		Endif
		
		
		With This
			Local lnCriteriu,lnCriteriu2, lcNume, lcNume2
			lnCriteriu = .criteriu.Value
			lnCriteriu2 = .criteriu2.Value
		
			lcNume = .Text.Value
			lcNume2 = .text2.Value
		
			If Type("pcValoare1") = "C" && variabila privata folosita in ck_filtru_text pt a initializa proprietatea cValoare1
				pcValoare1 = lcNume
			Endif
			If Type("pcValoare2") = "C" && variabila privata folosita in ck_filtru_text pt a initializa proprietatea cValoare2
				pcValoare2 = lcNume2
			Endif
			If Type("pnCriteriu")="N"
				pnCriteriu = lnCriteriu
			Endif
			If Type("pnCriteriu2")="N"
				pnCriteriu2 = lnCriteriu2
			Endif
		
			If Empty(lnCriteriu)
				.filtru = ""
				Return This.filtru
			Endif
		
			Do Case
				Case lnCriteriu = 1
					.filtru = "LIKE([" + Upper(lcNume) + "*]," + [upper(] + .camp_nume + [))]
				Case lnCriteriu = 2
					.filtru = [upper(] + .camp_nume + ")=[" + Upper(lcNume) + "]"
				Case lnCriteriu = 3
					.filtru = [upper(] + .camp_nume + ")<>[" + Upper(lcNume) + "]"
				Case lnCriteriu = 4
					.filtru = "LIKE([*" + Upper(lcNume) + "*]," + [upper(] + .camp_nume + [))]
				Case lnCriteriu = 5
					*.filtru = "upper(" + .camp_nume + ") NOT LIKE %" + UPPER(lcNume) + "%"
					.filtru = "!LIKE([*" + Upper(lcNume) + "*]," + [upper(] + .camp_nume + [))]
			Endcase
		
			If !Empty(lcIntre) && AND !EMPTY(lcNume2)
		
				Do Case
					Case lnCriteriu2 = 1
						.filtru = [(] + .filtru + lcIntre + "LIKE([" + Upper(lcNume2) + "*]," + [upper(] + .camp_nume + [)))]
					Case lnCriteriu2 = 2
						.filtru = [(] + .filtru + lcIntre + [upper(] + .camp_nume + ")=[" + Upper(lcNume2) + "])"
					Case lnCriteriu2 = 3
						.filtru = [(] + .filtru + lcIntre + [upper(] + .camp_nume + ")<>[" + Upper(lcNume2) + "])"
					Case lnCriteriu2 = 4
						.filtru = [(] + .filtru + lcIntre + "LIKE([*" + Upper(lcNume2) + "*]," + [upper(] + .camp_nume + [)))]
					Case lnCriteriu2 = 5
						.filtru = [(] + .filtru + lcIntre + "!LIKE([*" + Upper(lcNume2) + "*]," + [upper(] + .camp_nume + [)))]
				Endcase
			Endif
		
		Endwith
		
	ENDPROC

	PROCEDURE Init
		LPARAMETERS lcCampNume,lcTitlu,lnCriteriu,lnCriteriu2
		
		DODEFAULT()
		lctitlu=STRTRAN(lcTitlu,'\<','')
		WITH this
			.criteriu.value = lnCriteriu
			.criteriu2.value = lnCriteriu2
			.camp_nume = lcCampNume
			.lb_titlu_alb_b121.Caption=UPPER(lcTitlu)
			.text.ToolTipText='Introduceti expresia cu care se compara ' + lower(lcTitlu)
			.text2.ToolTipText='Introduceti expresia cu care se compara ' + lower(lcTitlu)
			IF EMPTY(lccampnume)
				.text.Enabled = .F.
				.criteriu.Enabled = .F.
				.text2.Enabled = .F.
				.criteriu2.Enabled = .F.
			ENDIF 
		ENDWITH 
	ENDPROC

	PROCEDURE Unload
		RETURN this.filtru 
	ENDPROC

	PROCEDURE Criteriu.InteractiveChange
		thisform.text.SetFocus 
	ENDPROC

	PROCEDURE Criteriu2.InteractiveChange
		thisform.text2.SetFocus 
	ENDPROC

	PROCEDURE Optiongroup1.Valid
		IF this.Value # 3
			thisform.Height = 155
		ELSE 
			thisform.Height = 111
		ENDIF 
	ENDPROC

	PROCEDURE Text.LostFocus
		
		
	ENDPROC

	PROCEDURE Text2.LostFocus
		
		
	ENDPROC

ENDDEFINE
