*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="frm_stornare_plinc.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_renunt1 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="Ct_clb_fdoc" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_nract" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_cont" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_partener" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_perioadaref" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cSerie_act.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cSerie_act.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cNract.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cNract.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cDataact.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cDataact.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cFdoc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cFdoc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cCod.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_documente.cCod.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_dataireg" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_dataact" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_cont
		*m: do_cauta_document
		*m: do_cauta_partener
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 560
		Name = "Frm_termin_renunt1"
		Width = 731
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 732
		_shape2.Height = 29
		_shape2.Left = 669
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 62
		Lb_titlu_alb_b121.Caption = "Stornare plată / încasare"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 11
		BUT_TERMIN1.Left = 700
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 9
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 334
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 38
		But_renunt1.Left = 671
		But_renunt1.Name = "But_renunt1"
		But_renunt1.TabIndex = 10
		But_renunt1.Top = 1
	*</PropValue>

	ADD OBJECT 'Clb_dataact' AS clb_tx_data WITH ;
		Height = 29, ;
		Left = 12, ;
		Name = "Clb_dataact", ;
		TabIndex = 3, ;
		Top = 94, ;
		Width = 312, ;
		Text_simplu1.ControlSource = "poRec.dataact", ;
		Text_simplu1.Left = 125, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 148, ;
		Lb_simplu1.Caption = "Data documentului", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Cmd_buton1.Left = 277, ;
		Cmd_buton1.Name = "Cmd_buton1", ;
		Cmd_buton1.Top = 2
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_dataireg' AS clb_tx_data WITH ;
		Height = 29, ;
		Left = 12, ;
		Name = "Clb_dataireg", ;
		TabIndex = 1, ;
		Top = 38, ;
		Width = 312, ;
		Text_simplu1.ControlSource = "poRec.dataireg", ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.Left = 125, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Width = 148, ;
		Lb_simplu1.Caption = "Dată înregistrare", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Cmd_buton1.Left = 277, ;
		Cmd_buton1.Name = "Cmd_buton1", ;
		Cmd_buton1.Top = 2
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_nract' AS clb_tx_simplu WITH ;
		Left = 12, ;
		Name = "Clb_nract", ;
		TabIndex = 4, ;
		Top = 122, ;
		Width = 312, ;
		Text_simplu1.ControlSource = "poRec.nract", ;
		Text_simplu1.Left = 123, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Lb_simplu1.Caption = "Nr. documentului", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_perioadaref' AS clb_nr_intre WITH ;
		Height = 29, ;
		Left = 370, ;
		Name = "Clb_perioadaref", ;
		TabIndex = 7, ;
		Top = 107, ;
		Width = 312, ;
		tx_n1.ControlSource = "poRec.datai", ;
		tx_n1.Height = 23, ;
		tx_n1.Left = 124, ;
		tx_n1.Name = "tx_n1", ;
		tx_n1.Top = 3, ;
		tx_n1.Width = 79, ;
		Lb_simplu1.Caption = "Perioada de referință", ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		tx_n2.ControlSource = "poRec.dataf", ;
		tx_n2.Height = 23, ;
		tx_n2.Left = 228, ;
		tx_n2.Name = "tx_n2", ;
		tx_n2.Top = 3, ;
		tx_n2.Width = 80
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_cont' AS ct_clb_cautare_var WITH ;
		cconditie = EMPTY(NVL(poRec.cont,'')), ;
		cprocedura = Thisform.do_cauta_cont, ;
		ctooltip = Alegeti contul, ;
		cvar_afisata = poRec.cont, ;
		Left = 369, ;
		Name = "Ct_clb_cont", ;
		TabIndex = 5, ;
		Top = 50, ;
		shape_cautare.Name = "shape_cautare", ;
		img_cautare.Name = "img_cautare", ;
		lb_cautare.Caption = "Cont", ;
		lb_cautare.Left = 9, ;
		lb_cautare.Name = "lb_cautare", ;
		lb_cautare.Top = 8, ;
		tx_cautare.Name = "tx_cautare"
		*< END OBJECT: ClassLib="..\comun\clase\caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_fdoc' AS ct_clb_cautare_var WITH ;
		cconditie = EMPTY(NVL(poRec.id_fdoc,0)), ;
		cprocedura = Thisform.do_cauta_document, ;
		ctooltip = Alegeti felul documentului, ;
		cvar_afisata = poRec.fdoc, ;
		Left = 11, ;
		Name = "Ct_clb_fdoc", ;
		TabIndex = 2, ;
		Top = 65, ;
		shape_cautare.Name = "shape_cautare", ;
		img_cautare.Name = "img_cautare", ;
		lb_cautare.Caption = "Felul documentului", ;
		lb_cautare.Left = 9, ;
		lb_cautare.Name = "lb_cautare", ;
		lb_cautare.Top = 8, ;
		tx_cautare.Name = "tx_cautare"
		*< END OBJECT: ClassLib="..\comun\clase\caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_partener' AS ct_clb_cautare_var WITH ;
		cconditie = EMPTY(NVL(poRec.id_part,0)), ;
		cprocedura = Thisform.do_cauta_partener, ;
		ctooltip = Alegeti partenerul, ;
		cvar_afisata = poRec.denumire, ;
		Left = 369, ;
		Name = "Ct_clb_partener", ;
		TabIndex = 6, ;
		Top = 78, ;
		shape_cautare.Name = "shape_cautare", ;
		img_cautare.Name = "img_cautare", ;
		lb_cautare.Caption = "Partener", ;
		lb_cautare.Left = 9, ;
		lb_cautare.Name = "lb_cautare", ;
		lb_cautare.Top = 8, ;
		tx_cautare.Name = "tx_cautare"
		*< END OBJECT: ClassLib="..\comun\clase\caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'grd_documente' AS _grdrow WITH ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		Height = 360, ;
		Left = 12, ;
		Name = "grd_documente", ;
		Panel = 1, ;
		RecordSource = "crsDocumenteStorno", ;
		TabIndex = 8, ;
		Top = 192, ;
		Width = 708, ;
		Column1.ControlSource = "serie_act", ;
		Column1.Name = "cSerie_act", ;
		Column2.ControlSource = "nract", ;
		Column2.Name = "cNract", ;
		Column2.Width = 96, ;
		Column3.ControlSource = "TTOD(dataact)", ;
		Column3.Name = "cDataact", ;
		Column4.ControlSource = "fdoc", ;
		Column4.Name = "cFdoc", ;
		Column5.ControlSource = "cod", ;
		Column5.Name = "cCod"
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_documente.cCod.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

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

	ADD OBJECT 'grd_documente.cFdoc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Fel document", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grd_documente.cNract.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. doc.", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grd_documente.cSerie_act.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Serie doc.", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'Lb_simplu1' AS lb_simplu WITH ;
		Caption = "Faceți click pe linia corespunzătoare documentului pe care doriți să-l stornați :", ;
		Left = 12, ;
		Name = "Lb_simplu1", ;
		TabIndex = 12, ;
		Top = 169
		*< END OBJECT: ClassLib="..\comun\clase\lb.vcx" BaseClass="label" />
	
	PROCEDURE Destroy
		Unbindevents(poRec,"cont",Thisform,"do_cauta")
		Unbindevents(poRec,"id_part",Thisform,"do_cauta")
		Unbindevents(poRec,"datai",Thisform,"do_cauta")
		Unbindevents(poRec,"dataf",Thisform,"do_cauta")
	ENDPROC

	PROCEDURE do_cauta
		If !Empty(Nvl(poRec.Cont,'')) And !Empty(Nvl(poRec.tip_sold,'')) And !Empty(Nvl(poRec.id_part,0)) ;
				And !Empty(Nvl(poRec.datai,{})) And !Empty(Nvl(poRec.dataf,{}))
			With Thisform.grd_documente
				lcCursor = .RecordSource
				.salveaza_grid()
				lcSql = [select distinct serie_act, nract, dataact, fdoc, cod from vact ] + ;
					[where ] + ;
					IIF(poRec.tip_sold = 'P', [scd = '] + ALLTRIM(NVL(poRec.Cont, '')) + [' and id_partd = ] + ALLTRIM(STR(poRec.id_part)),[scc = '] + ALLTRIM(NVL(poRec.Cont, '')) + [' and id_partc = ] + ALLTRIM(STR(poRec.id_part))) + ;
					[ and dataact between to_date('] + DTOS(poRec.datai)+ [','yyyymmdd') and to_date('] + DTOS(poRec.dataf)+ [','yyyymmdd')] + ;
					[order by dataact]
				If goExecutor.oExecuta(lcSql,lcCursor)
					If Reccount(lcCursor) = 0
						amessagebox("Cautarea nu a intors rezultate!",64,"Atentie")
					Endif
				Endif
				.incarca_grid()
				.AutoFit()
			Endwith
		Endif
	ENDPROC

	PROCEDURE do_cauta_cont
		Local loCauta
		loCauta = caut_cont(,,,.T.)
		If !Isnull(loCauta) And !Empty(loCauta.Cont)
			poRec.Cont = Alltrim(loCauta.Cont)
			poRec.tip_sold = Alltrim(loCauta.tip_sold)
		
			This.ct_clb_cont.Refresh()
			This.ct_clb_partener.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_document
		Local loCauta
		loCauta = caut_fdoc()
		If !Isnull(loCauta) And !Empty(loCauta.fel_document)
			poRec.id_fdoc = loCauta.id_fdoc
			poRec.fdoc = loCauta.fel_document
		
			This.ct_clb_fdoc.Refresh()
			This.clb_dataact.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta_partener
		Local loCauta
		loCauta = CautPartenerContabilitate(GetHash([cCont=>]+Alltrim(poRec.Cont)))
		If !Empty(Nvl(loCauta.id_part,0)) And !Empty(loCauta.denumire)
			poRec.id_part = loCauta.id_part
			poRec.denumire = loCauta.denumire
		
			This.ct_clb_partener.Refresh()
			This.clb_perioadaref.SetFocus()
		Endif
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local llReturn
		llReturn = .F.
		
		Do Case
		Case Empty(Nvl(poRec.dataireg,{}))
			amessagebox("Nu ati completat data inregistrarii!",48,"Atentie")
			Thisform.clb_dataireg.SetFocus()
		Case Empty(Nvl(poRec.id_fdoc,0))
			amessagebox("Nu ati ales felul documentului!",48,"Atentie")
			Thisform.ct_clb_fdoc.SetFocus()
		Case Empty(Nvl(poRec.dataact,{}))
			amessagebox("Nu ati completat data documentului!",48,"Atentie")
			Thisform.clb_dataact.SetFocus()
		Case Empty(Nvl(poRec.nract,0))
			amessagebox("Numarul documentului trebuie sa fie diferit de 0!",48,"Atentie")
			Thisform.clb_nract.SetFocus()
		Case Reccount(Thisform.grd_documente.RecordSource) = 0
			amessagebox("Nu ati ales documentul pentru care se face stornarea!",48,"Atentie")
			Thisform.grd_documente.SetFocus()
		Otherwise
			poRec.cursor = Thisform.grd_documente.RecordSource
			llReturn = .T.
		Endcase
		
		Return llReturn
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Bindevent(poRec,"cont",Thisform,"do_cauta",1)
		Bindevent(poRec,"id_part",Thisform,"do_cauta",1)
		Bindevent(poRec,"datai",Thisform,"do_cauta",1)
		Bindevent(poRec,"dataf",Thisform,"do_cauta",1)
		
	ENDPROC

	PROCEDURE Clb_dataireg.Text_simplu1.LostFocus
		poRec.dataact = poRec.dataireg
		Thisform.clb_dataact.Refresh()
	ENDPROC

ENDDEFINE
