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

	*<PropValue>
		DataSource = .NULL.
		Height = 0
		Left = 0
		Name = "Dataenvironment"
		Top = 0
		Width = 0
	*</PropValue>

ENDDEFINE

DEFINE CLASS frm_termin_renunt12 AS frm_termin_renunt OF "..\comun\clase\_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtgestiuni" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="OptCont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="optgestiuni" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="OptResponsabil" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="OptSectii" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: ctitlu
		*p: nfiscala
		*p: ntip
		*p: orezult
		*p: pcvalue_txt
	*</DefinedPropArrayMethod>

	*<PropValue>
		ctitlu = 
		DataSession = 1
		DoCreate = .T.
		Height = 236
		Name = "Frm_termin_renunt12"
		nfiscala = 0
		ntip = 1
		orezult = 
		pcvalue_txt = 
		Width = 388
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 388
		_SHAPE2.Height = 29
		_SHAPE2.Left = 324
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Width = 64
		LB_TITLU_ALB_B121.Caption = "Alegeti parametrii raportului"
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		BUT_TERMIN1.Left = 356
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
		But_renunt1.Left = 327
		But_renunt1.Name = "But_renunt1"
		But_renunt1.Top = 1
	*</PropValue>

	ADD OBJECT '_txtgestiuni' AS _textbox WITH ;
		ControlSource = "thisform.pcvalue_txt", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 119, ;
		Name = "_txtgestiuni", ;
		TabIndex = 9, ;
		Top = 118, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		Left = 335, ;
		Name = "But_cautare1", ;
		TabIndex = 12, ;
		Top = 114
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ed_tx_simplu1' AS ed_tx_simplu WITH ;
		Height = 33, ;
		Left = 15, ;
		Name = "Ed_tx_simplu1", ;
		TabIndex = 1, ;
		Top = 42, ;
		Width = 360, ;
		_edbase1.ControlSource = "thisform.ctitlu", ;
		_edbase1.FontName = "Arial Narrow", ;
		_edbase1.FontSize = 10, ;
		_edbase1.Format = "k", ;
		_edbase1.Height = 27, ;
		_edbase1.Left = 76, ;
		_edbase1.Name = "_edbase1", ;
		_edbase1.TabIndex = 1, ;
		_edbase1.Top = 3, ;
		_edbase1.Width = 278, ;
		_lbbase1.Caption = "Titlu raport", ;
		_lbbase1.FontSize = 10, ;
		_lbbase1.Left = 11, ;
		_lbbase1.Name = "_lbbase1", ;
		_lbbase1.TabIndex = 2, ;
		_lbbase1.Top = 7
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Label1' AS label WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		BackColor = 255,255,255, ;
		Caption = "Grupat dupa", ;
		Comment = "*:OnResize=LT", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 23, ;
		Name = "Label1", ;
		TabIndex = 11, ;
		Top = 76, ;
		Width = 73, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Alignment = 2, ;
		AutoSize = .T., ;
		BackColor = 255,255,255, ;
		Caption = "Subgrupat dupa", ;
		Comment = "*:OnResize=LT", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 23, ;
		Name = "Label2", ;
		TabIndex = 10, ;
		Top = 175, ;
		Width = 93, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'OptCont' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 1, ;
		Height = 28, ;
		Left = 20, ;
		Name = "OptCont", ;
		SpecialEffect = 1, ;
		TabIndex = 3, ;
		Top = 193, ;
		Value = 0, ;
		Width = 56, ;
		ZOrderSet = 17, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Cont", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 0, ;
		Option1.Width = 46
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'optgestiuni' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 1, ;
		Height = 28, ;
		Left = 19, ;
		Name = "optgestiuni", ;
		SpecialEffect = 1, ;
		TabIndex = 2, ;
		Top = 94, ;
		Value = 0, ;
		Width = 81, ;
		ZOrderSet = 15, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Gestiune", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 0, ;
		Option1.Width = 71
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'OptResponsabil' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 1, ;
		Height = 28, ;
		Left = 19, ;
		Name = "OptResponsabil", ;
		SpecialEffect = 1, ;
		TabIndex = 2, ;
		Top = 117, ;
		Value = 0, ;
		Width = 100, ;
		ZOrderSet = 15, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Responsabil", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 0, ;
		Option1.Width = 90
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'OptSectii' AS optiongroup WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		BorderStyle = 0, ;
		ButtonCount = 1, ;
		Height = 28, ;
		Left = 19, ;
		Name = "OptSectii", ;
		SpecialEffect = 1, ;
		TabIndex = 2, ;
		Top = 140, ;
		Value = 0, ;
		Width = 66, ;
		ZOrderSet = 15, ;
		Option1.AutoSize = .T., ;
		Option1.BackStyle = 0, ;
		Option1.Caption = "Sectie", ;
		Option1.FontSize = 10, ;
		Option1.Height = 18, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option1.Value = 0, ;
		Option1.Width = 56
		*< END OBJECT: BaseClass="optiongroup" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		BackStyle = 0, ;
		Height = 85, ;
		Left = 15, ;
		Name = "Shape1", ;
		Top = 86, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		Height = 38, ;
		Left = 15, ;
		Name = "Shape2", ;
		Top = 185, ;
		Width = 360, ;
		ZOrderSet = 0
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE do_cauta
		IF THIS.optgestiuni.VALUE = 1
			pcselect = [select * from ] + gcs + [.vnom_GESTIUNI]
			pcFiltruOrig = [inactiv = 0 ]
			pcfiltru = [2=2]
			pcschema = ['']
			pcorder = [nume_gestiune]
			pccoloane = [nume_gestiune,cgest]
			pcTitlu = [Alegeti gestiunea]
			pcTitluColoane = [Gestiune,Indicativ]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"",.T.,pcFiltruOrig)
			THIS.pcvalue_txt = locauta.nume_gestiune
		ENDIF
		
		IF THIS.optResponsabil.VALUE = 1
			pcselect = [select * from ] + gcs + [.vNom_responsabili]
			pcFiltruOrig = [inactiv = 0]
			pcfiltru = [2=2]
			pcschema = ['']
			pcorder = [nume]
			pccoloane = [nume]
			pcTitlu = [Alegeti responsabilul]
			pcTitluColoane = [Responsabil]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"",.T.,pcFiltruOrig)
			THIS.pcvalue_txt = locauta.nume
		ENDIF
		
		IF THIS.optSectii.VALUE = 1
			pcselect = [select * from ] + gcs + [.vnom_sectii]
			pcFiltruOrig = [inactiv = 0 ]
			pcfiltru = [2=2]
			pcschema = ['']
			pcorder = [sectie,csectie]
			pccoloane = [sectie,csectie]
			pcTitlu = [Alegeti sectia]
			pcTitluColoane = [Sectie,Indicativ]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"",.T.,pcFiltruOrig)
			THIS.pcvalue_txt = locauta.sectie
		ENDIF
		
		THIS._txtgestiuni.REFRESH
		THIS.orezult = locauta
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Private postocuri, pcschema, pcselect, pcfiltru, pcorder, osel, pcFiltruOriginal, pcGrupCont, pcGrupAcont
		Local lcCursor, lcFiltru, lcOrder, lcRaport, lcSchema, lcSel, llExperimental, llSucces
		PRIVATE nGest, nResp, nSectie, pcCond, pcDataora, pcGrup1, pcGrup2, pcHeaderGrup, pcHeaderGrup1
		PRIVATE pcHeaderGrup2, pcTitlu, pdDataF, pdDataI, pnFiscala, pnTip
		Store [] To postocuri, pcFiltruOriginal, pcHeaderGrup
		
		nGest = 0
		nResp = 0
		nSectie = 0
		
		osel = This.orezult
		pnTip = This.ntip
		pcFiltruOriginal = [id_tip_imobilizare=?pnTip and iesit_din_gest=0]
		lcOrder = []
		pcGrup1 = [EOF()]
		pcGrup2 = [EOF()]
		pcHeaderGrup1 = []
		pcHeaderGrup2 = []
		
		If This.optgestiuni.Value = 1
		*!*		If Type('osel') # 'O'
		*!*			aMessagebox('Alegeti gestiunea', 0 + 48)
		*!*			Return .F.
		*!*		Endif
		
			If Type('osel') = 'O' AND Alltrim(osel.nume_gestiune) # [<TOATE INREGISTRARILE>]
				nGest = osel.id_gestiune
				pcFiltruOriginal = pcFiltruOriginal + [ and id_gestiune = ?nGest]
			Endif
			pcGrup1 = [gestiune]
			lcOrder = lcOrder + [,gestiune]
			pcHeaderGrup1 = [Gestiune : ]
		Endif
		
		If This.optResponsabil.Value = 1
		*!*		If Type('osel') # 'O'
		*!*			aMessagebox('Alegeti Responsabilul', 0 + 48)
		*!*			Return .F.
		*!*		Endif
			If Type('osel') = 'O' AND Alltrim(osel.nume) # [<TOATE INREGISTRARILE>]
				nResp = osel.id_responsabil
				pcFiltruOriginal = pcFiltruOriginal + [ and id_responsabil=?nResp]
			Endif
			pcGrup1 = [responsabil]
			lcOrder = lcOrder + [,responsabil]
			pcHeaderGrup1 = [Responsabil : ]
		Endif
		
		If This.optSectii.Value = 1
		*!*		If Type('osel') # 'O'
		*!*			aMessagebox('Alegeti sectia', 0 + 48)
		*!*			Return .F.
		*!*		Endif
			If Type('osel') = 'O' AND Alltrim(osel.sectie) # [<TOATE INREGISTRARILE>]
				nSectie = osel.id_sectie
				pcFiltruOriginal = pcFiltruOriginal + [ and id_sectie = ?nSectie]
			Endif
			pcGrup1 = [sectie]
			lcOrder = lcOrder + [,sectie]
			pcHeaderGrup1 = [Sectia : ]
		Endif
		
		If This.optCont.Value = 1
			pcGrup2 = [cont]
			lcOrder = lcOrder + [,cont,acont]
			pcHeaderGrup2 = [Cont : ]
		Endif
		
		lcOrder = lcOrder + [,data_pif,nr_pif,denumire,cod_mf]
		lcOrder = Substr(lcOrder, 2)
		
		pdDataI = Date(gnAn, gnLuna, 1)
		pdDataF = pdDataI
		pcCond = [1=1]
		pnFiscala = Thisform.nFiscala
		lcSchema = ['']
		lcCursor = 'crslista'
		
		llExperimental = .T. && 25.11.2021 llExperimental = (goApp.nExperimental = 1)
		If m.llExperimental
			* EXPERIMENTAL SELECTIE DIN IMOB_VSITUATIE_LUNARA IN LOC DE PACK_IMOB.CALCUL_SITUATIE_LUNARA()
			* Setez luna pentru view
			lcFiltru = m.pcFiltruOriginal + m.gcCondSucursala
		
			llSucces = goExecutor.oExecuta('begin pack_imob.setlunacurenta(?pdDataI); end;')
			If m.llSucces
				lcSel = [SELECT * FROM ] + Iif(m.pnFiscala = 0, [imob_vsituatie_lunara], [imobf_vsituatie_lunara]) + [ WHERE ] + m.lcFiltru
				llSucces = goExecutor.oExecuta(m.lcSel, m.lcCursor)
			Endif
		Else
			lcSel = [{call pack_imob.CALCUL_SITUATIE_LUNARA(?pdDataI,?pdDataF,?pcCond,?pnFiscala,?gnIdSucursala)}]
			llSucces = goExecutor.oExecuta(lcSel, lcCursor)
		Endif
		
		If !m.llSucces
			Return .F.
		Endif
		*Select * from crslista order by data_operatie,nr_inventar into crslista 
		
		pcTitlu = Thisform.ctitlu
		
		Select * From crslista With (Buffering = .T.) Where &pcFiltruOriginal Into Cursor crs_rap Order By &lcOrder
		If Used('crsLista')
			Use In crslista
		Endif
		Select crs_rap
		*!*	modificare	 v 2.0.7
		*!*	Index on DTOS(data_PIF)+STR(nr_inventar) tag ordine
		*!*	modificare	 v 2.0.7	^
		If Reccount('crs_rap') > 0
			pcDataora = get_Ora(2)
			Select crs_rap
			Thisform.AlwaysOnTop = .F.
			lcRaport = [list_mfgrup.frx]
			goExport.export2frx([crs_rap], m.lcRaport, , , , , , .T.)	
			*Report Format &lcRaport To Printer Prompt Noconsole Preview
			Thisform.AlwaysOnTop = .T.
		Else
			aMessagebox("Nu exista inregistrari pentru listare!", 48, "Atentie")
		Endif
		Use In crs_rap
		
		Return .F.
		
	ENDPROC

	PROCEDURE Init
		PARAMETERS tnTip, tnFiscala
		thisform.ntip = tnTip
		this.nfiscala = tnFiscala
		DODEFAULT()
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.ctitlu="LISTA IMOBILIZARILOR "+IIF(this.nTip=1,"CORPORALE","NECORPORALE")+" IN LUNA " + allt(str(gnLuna)) + ' / ' + allt(str(gnAn))
		this.Ed_tx_simplu1.Refresh 
		
	ENDPROC

	PROCEDURE optgestiuni.InteractiveChange
		thisform.pcvalue_txt = []
		thisform.optResponsabil.Value = 0
		thisform.optSectii.Value = 0
		thisform._txtgestiuni.refresh
		thisform.ResetToDefault('orezult')
	ENDPROC

	PROCEDURE OptResponsabil.InteractiveChange
		thisform.pcvalue_txt = []
		thisform._txtgestiuni.refresh
		thisform.optGestiuni.Value = 0
		thisform.optSectii.Value = 0
		thisform.ResetToDefault('orezult')
	ENDPROC

	PROCEDURE OptSectii.InteractiveChange
		thisform.pcvalue_txt = []
		thisform._txtgestiuni.refresh
		thisform.optGestiuni.Value = 0
		thisform.optResponsabil.Value = 0
		thisform.ResetToDefault('orezult')
	ENDPROC

ENDDEFINE
