*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="odeschidereluna.vcx" CPID="1250" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS frm_log_deschidereluna 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="grdLogRedeschid" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cAn.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cAn.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cLuna.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cLuna.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDeschid.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDeschid.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDeschid._CHECKBOX1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cProgramat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cProgramat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cProgramat._CHECKBOX1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora_start.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora_start.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora_final.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora_final.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cUtilizator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cUtilizator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataora.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cSters.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cSters.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cSters._CHECKBOX1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cUtilizators.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cUtilizators.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataoras.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cDataoras.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cObservatii.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grdLogRedeschid.cObservatii.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_start_criterii1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: cfile
	*</DefinedPropArrayMethod>

	*<PropValue>
		cfile = 
		DoCreate = .T.
		Height = 455
		Name = "frm_log_deschidereluna"
		Width = 626
		WindowState = 2
		_SHAPE1.Anchor = 10
		_SHAPE1.Height = 29
		_SHAPE1.Left = 0
		_SHAPE1.Name = "_SHAPE1"
		_SHAPE1.Top = 0
		_SHAPE1.Width = 630
		_SHAPE2.Left = 576
		_SHAPE2.Name = "_SHAPE2"
		_SHAPE2.Top = 0
		_SHAPE2.Visible = .F.
		LB_TITLU_ALB_B121.Caption = "Programare deschidere / redeschidere luna"
		LB_TITLU_ALB_B121.Name = "LB_TITLU_ALB_B121"
		LB_TITLU_ALB_B121.TabIndex = 10
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 596
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 8
		BUT_TERMIN1.Top = 1
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

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

	ADD OBJECT 'But_start_criterii1' AS but_start_criterii WITH ;
		Anchor = 9, ;
		Comment = "*:OnResize=RT", ;
		Left = 503, ;
		Name = "But_start_criterii1", ;
		Top = 0
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'grdLogRedeschid' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 12, ;
		DeleteMark = .F., ;
		Height = 408, ;
		Left = 12, ;
		Name = "grdLogRedeschid", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "cLogRedeschid", ;
		TabIndex = 4, ;
		Top = 36, ;
		Width = 600, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "anul", ;
		Column1.Name = "cAn", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 43, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "luna", ;
		Column2.Name = "cLuna", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 46, ;
		Column3.ControlSource = "deschid", ;
		Column3.CurrentControl = "_CHECKBOX1", ;
		Column3.Name = "cDeschid", ;
		Column3.ReadOnly = .T., ;
		Column3.Sparse = .F., ;
		Column3.Width = 72, ;
		Column4.ControlSource = "programat", ;
		Column4.CurrentControl = "_CHECKBOX1", ;
		Column4.Name = "cProgramat", ;
		Column4.ReadOnly = .T., ;
		Column4.Sparse = .F., ;
		Column4.Width = 62, ;
		Column5.ControlSource = "dataora_start", ;
		Column5.Name = "cDataora_start", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 110, ;
		Column6.ControlSource = "dataora_stop", ;
		Column6.Name = "cDataora_final", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 110, ;
		Column7.ControlSource = "utilizator", ;
		Column7.Name = "cUtilizator", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 162, ;
		Column8.ControlSource = "dataora", ;
		Column8.Name = "cDataora", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 96, ;
		Column9.ControlSource = "sters", ;
		Column9.CurrentControl = "_CHECKBOX1", ;
		Column9.Name = "cSters", ;
		Column9.ReadOnly = .T., ;
		Column9.Sparse = .F., ;
		Column9.Width = 41, ;
		Column10.ControlSource = "utilizators", ;
		Column10.Name = "cUtilizators", ;
		Column10.ReadOnly = .T., ;
		Column10.Width = 158, ;
		Column11.ControlSource = "dataoras", ;
		Column11.Name = "cDataoras", ;
		Column11.ReadOnly = .T., ;
		Column11.Width = 106, ;
		Column12.ControlSource = "observatii", ;
		Column12.Name = "cObservatii", ;
		Column12.ReadOnly = .T., ;
		Column12.Width = 165
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grdLogRedeschid.cAn.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "An", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cDataora.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data/ora", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cDataora_final.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data/ora final", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cDataora_start.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data/ora start", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cDataoras.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data/ora sters", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cDeschid._CHECKBOX1' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "", ;
		Left = 30, ;
		Name = "_CHECKBOX1", ;
		ReadOnly = .T., ;
		Top = 71
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grdLogRedeschid.cDeschid.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Deschidere", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cLuna.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Luna", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cObservatii.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Observatii", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cProgramat._CHECKBOX1' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "", ;
		Left = 41, ;
		Name = "_CHECKBOX1", ;
		ReadOnly = .T., ;
		Top = 71
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grdLogRedeschid.cProgramat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Programat", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cSters._CHECKBOX1' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "", ;
		Left = 17, ;
		Name = "_CHECKBOX1", ;
		ReadOnly = .T., ;
		Top = 47
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grdLogRedeschid.cSters.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Sters", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cUtilizator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Operator", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grdLogRedeschid.cUtilizators.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Operator stergere", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grdLogRedeschid.cUtilizators.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE do_adauga
		PRIVATE pnId
		pnId = 0
		
		lcSql = [begin pack_deschidere_luna.adauga_programare(?gnAn, ?gnLuna, pack_deschidere_luna.nRedeschidereLuna, ?gnIdUtil, ?gnIdProgram, ?@pnId); end;]
		lnSucces = goExecutor.oExecute(lcSql)
		IF lnSucces < 0
			aMESSAGEBOX(goExecutor.cEroare,0+16,_screen.Caption)
		ELSE 
			This.do_cauta()	
			LOCATE FOR id_redeschid = pnId
			IF !FOUND()
				GO TOP 
			ENDIF 
			this.grdLogRedeschid.SetFocus()
		ENDIF 	
		
	ENDPROC

	PROCEDURE do_cauta
		LOCAL lcFiltru
		lcFiltru = ""
		
		*** DACA FILTRUL NU CONTINE INREGISTRARILE STERSE, SELECTEZ DOAR INREGISTRARILE STERS = 0
		If !'STERS'$upper(Thisform.filtru_pretty_ro_full)
			lcFiltru = [ AND STERS = 0 ] + lcFiltru
		ENDIF
		
		*** DACA FILTRUL NU CONTINE PERIOADA, SELECTEZ DOAR INREGISTRARILE DIN LUNA CURENTA
		IF !'PERIOADA'$upper(THISFORM.filtru_pretty_ro_full)
			lcFiltru = [ AND LUNA = ]+ALLTRIM(STR(m.gnluna))+[ AND ANUL = ]+ALLTRIM(STR(m.gnan)) + m.lcFiltru
		ENDIF
		
		IF LEN(THISFORM.filtru_pretty)>0     
			lcFiltru = m.lcFiltru+" and (" + ALLTRIM(THISFORM.filtru_pretty) + ")"    
		ENDIF
		
		IF !EMPTY(m.lcFiltru)
			lcFiltru = SUBSTR(m.lcFiltru, 6)
		ELSE 
			lcFiltru = poProgramare.ca_baza1.cfiltru
		ENDIF 	
		
		IF (THIS.filtru_pretty#"none")
			Thisform.MousePointer= 11
			Thisform.LockScreen=.T.
			save_grid_tag(Thisform.grdLogRedeschid)
			poProgramare.ca_baza1.cfiltru = m.lcFiltru
			poProgramare.ca_baza1.afisare()
			restore_grid_tag(Thisform.grdLogRedeschid)
			Thisform.LockScreen=.F.
			Thisform.MousePointer= 0
		
			IF RECCOUNT('cLogRedeschid')=0
				aMessagebox("Cautarea nu a intors rezultate!",0+48,_screen.Caption)
			ENDIF
		ENDIF
		
		
		
		
		
	ENDPROC

	PROCEDURE inainte_de_do_sterge
		Private pnId
		pnId = cLogRedeschid.id_redeschid
		
		If Nvl(pnId,0) <> 0
			lcSql = [begin pack_deschidere_luna.sterge_programare(?pnId, ?gnIdUtil); end;]
			lnSucces = goExecutor.oExecute(lcSql)
			If lnSucces < 0
				aMESSAGEBOX(goExecutor.cEroare,0+16,_Screen.Caption)
			Else
				This.do_cauta()
				Locate For id_redeschid = pnId
				If !Found()
					Go Top
				Endif
				This.grdLogRedeschid.SetFocus()
			Endif
		Endif
		
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		this.grdLogRedeschid.SetAll("dynamicforecolor","iif(sters = 0, RGB(0,0,0), RGB(255,0,0))", "Column")
	ENDPROC

	PROCEDURE But_start_criterii1.loadcriterii
		
		PARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		#DEFINE crlf CHR(13)+CHR(10)
		
		lcStringCriterii=	"Perioada\anul*12+luna\D1\none\" + crlf + ;  
		    "Dataora start\trunc(dataora_start)\D\none\" + crlf + ; 
		    "Dataora final\trunc(dataora_final)\D\none\" + crlf + ;     
		    "Deschidere\nofiled\A\Deschidere de luna,Redeschidere de luna,Toate#NVL(deschid,0) = 1,NVL(deschid,0) = 0,1=1\" + crlf + ;    
		    "Programare\nofiled\A\Deschidere programata,Deschidere imediata,Toate#programat = 1,programat = 0,1=1\" + crlf + ;
		    "Dataora\trunc(dataora)\D\none\" + crlf + ; 
		    "Operator\util\T\ID_UTIL\nom_utilizator" + crlf + ;
		   	"Sterse\nofiled\E\(1=1)\" + crlf + ;
		    "Operator stergere\utils\T\ID_UTILS\nom_utilizator" + crlf + ; 
		    "Data stergerii\trunc(dataoras)\D\none\"
			
		DODEFAULT()
		
	ENDPROC

ENDDEFINE
