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

	*<PropValue>
		Name = "cus_odata_detalii"
	*</PropValue>
	
	PROCEDURE make_sql
		Lparameters toRec,tnId
		
		lcActiune = Alltrim(This.cActiune)
		lcId_util = Alltrim(Str(gnIdUtil))
		
		If Inlist(lcActiune, "UPDATE",'INSERT') And Type('toRec') != "O"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE') And Type('tnId') != "N"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE')
			lcId = Alltrim(Str(tnId))
		Endif
		
		If Inlist(lcActiune, "UPDATE",'INSERT')
			lcDataora = ALLTRIM(TTOC(toRec.dataora,1))
		ENDIF
		
		Do Case
		*!*	Case lcActiune = "INSERT"
		*!*		lcSql = [begin pack_preturi.adauga_politica(']+lcNume+[',]+;
		*!*			[to_date(']+lcDataI+[','YYYYMMDD'),to_date(']+lcDataS+[','YYYYMMDD'),]+;
		*!*			lcIdValuta+[,]+lcIdNota +[,]+lcId_util+[); end;]
		
		*!*	Case lcActiune = "UPDATE"
		*!*		lcSql = [begin pack_gest_vanzari.modifica_vanzare(]+lcId+;
		*!*			[,to_date(']+lcDataora+[','YYYYMMDDHH24:MI:SS'),]+;
		*!*			lcIdUtil +[,]+lcId_lucrare+[,]+lcId_part +[,]+lcNumar_act +[,]+lcNr_persoane +[,']+lcNrinmat +['); end;]
		
		Case lcActiune = "DELETE"
			lcSql = [begin pack_gest_vanzari.sterge_vanzare_det(]+lcId+[,]+lcId_util+[); end;]
		
		ENDCASE
		
		This.csql = lcSql
	ENDPROC

ENDDEFINE

DEFINE CLASS cus_odata_vanzari AS _cusodatabase OF "_cus_odata_base.vcx" 
 	*< CLASSDATA: Baseclass="custom" Timestamp="" Scale="Pixels" Uniqueid="" />

	*<PropValue>
		Name = "cus_odata_vanzari"
	*</PropValue>
	
	PROCEDURE make_sql
		Lparameters toRec,tnId
		
		lcActiune = Alltrim(This.cActiune)
		lcId_util = Alltrim(Str(gnIdUtil))
		
		If Inlist(lcActiune, "UPDATE",'INSERT') And Type('toRec') != "O"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE') And Type('tnId') != "N"
			Return .F.
		Endif
		
		If Inlist(lcActiune, "UPDATE",'DELETE')
			lcId = Alltrim(Str(tnId))
		Endif
		
		If Inlist(lcActiune, "UPDATE",'INSERT')
			lcDataora = ALLTRIM(TTOC(toRec.dataora,1))
			lcIdUtil = ALLTRIM(STR(toRec.id_util))
			lcId_lucrare = ALLTRIM(STR(toRec.id_lucrare))
			lcId_part = ALLTRIM(STR(toRec.id_part))
			lcNumar_act = NVL(ALLTRIM(STR(toRec.numar_act)),'0')
			lcNr_persoane = NVL(ALLTRIM(STR(toRec.nr_persoane)),'0')
			lcNrinmat = NVL(ALLTRIM(toRec.nrinmat),'')
			
			
		ENDIF
		
		Do Case
		*!*	Case lcActiune = "INSERT"
		*!*		lcSql = [begin pack_preturi.adauga_politica(']+lcNume+[',]+;
		*!*			[to_date(']+lcDataI+[','YYYYMMDD'),to_date(']+lcDataS+[','YYYYMMDD'),]+;
		*!*			lcIdValuta+[,]+lcIdNota +[,]+lcId_util+[); end;]
		
		Case lcActiune = "UPDATE"
			lcSql = [begin pack_gest_vanzari.modifica_vanzare(]+lcId+;
				[,to_date(']+lcDataora+[','YYYYMMDDHH24:MI:SS'),]+;
				lcIdUtil +[,]+lcId_lucrare+[,]+lcId_part +[,]+lcNumar_act +[,]+lcNr_persoane +[,']+lcNrinmat +['); end;]
		
		Case lcActiune = "DELETE"
			lcSql = [begin pack_gest_vanzari.sterge_vanzare(]+lcId+[,]+lcId_util+[); end;]
		
		ENDCASE
		
		This.csql = lcSql
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_alege_din_stoc 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="Ct_grid_search1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_grid_search1.Cb_tx_gestout" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_grid_search1.But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<PropValue>
		DoCreate = .T.
		Height = 462
		Name = "frm_alege_din_stoc"
		Width = 369
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 401
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 309
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 59
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 338
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 276
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 7
	*</PropValue>

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

	ADD OBJECT 'Ct_grid_search1' AS ct_grid_search WITH ;
		Anchor = 135, ;
		cnumecursor = cursor_curent1, ;
		Height = 425, ;
		Left = 5, ;
		Name = "Ct_grid_search1", ;
		TabIndex = 1, ;
		Top = 32, ;
		Width = 357, ;
		ZOrderSet = 15, ;
		_GRID1.Comment = "grd_st", ;
		_GRID1.FontName = "Arial Narrow", ;
		_GRID1.Height = 345, ;
		_GRID1.Left = 6, ;
		_GRID1.Name = "_GRID1", ;
		_GRID1.RecordSource = "cursor_curent", ;
		_GRID1.Top = 73, ;
		_GRID1.Width = 347, ;
		Titlu.Left = 9, ;
		Titlu.Name = "Titlu", ;
		Titlu.Top = 2, ;
		Cb_tx_cautare1.Criteriu.Comment = "criteriu_st", ;
		Cb_tx_cautare1.Criteriu.Name = "Criteriu", ;
		Cb_tx_cautare1.Height = 27, ;
		Cb_tx_cautare1.Left = 7, ;
		Cb_tx_cautare1.Name = "Cb_tx_cautare1", ;
		Cb_tx_cautare1.Text.Comment = "text_st", ;
		Cb_tx_cautare1.Text.Height = 25, ;
		Cb_tx_cautare1.Text.Left = 103, ;
		Cb_tx_cautare1.Text.Name = "Text", ;
		Cb_tx_cautare1.Text.Top = 1, ;
		Cb_tx_cautare1.Text.Width = 207, ;
		Cb_tx_cautare1.Top = 46, ;
		Cb_tx_cautare1.Width = 312
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_grid_search1.But_nou1' AS but_nou WITH ;
		Anchor = 9, ;
		Height = 27, ;
		Left = 322, ;
		Name = "But_nou1", ;
		TabStop = .F., ;
		Top = 45, ;
		ZOrderSet = 17
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_grid_search1.Cb_tx_gestout' AS cb_tx_simplu WITH ;
		BackStyle = 0, ;
		BorderColor = 255,255,255, ;
		Height = 24, ;
		Left = 7, ;
		Name = "Cb_tx_gestout", ;
		Top = 20, ;
		Width = 346, ;
		_cbbase1.BorderStyle = 0, ;
		_cbbase1.ColumnCount = 2, ;
		_cbbase1.ColumnLines = .F., ;
		_cbbase1.ColumnWidths = "180,30", ;
		_cbbase1.FontItalic = .F., ;
		_cbbase1.FontName = "Arial Narrow", ;
		_cbbase1.Height = 23, ;
		_cbbase1.Left = 101, ;
		_cbbase1.Name = "_cbbase1", ;
		_cbbase1.Top = 1, ;
		_cbbase1.Width = 243, ;
		_lbbase1.Caption = "gestiune sursa", ;
		_lbbase1.FontItalic = .T., ;
		_lbbase1.Left = 3, ;
		_lbbase1.Name = "_lbbase1", ;
		_lbbase1.Top = 4
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />
	
	PROCEDURE Init
		DoDefault()
		If Used('nom_gestiuni')
			With Thisform.ct_grid_search1.cb_tx_gestout._CBBASE1
				.ControlSource = [poact.gestout]
				.RowSource	= [nom_gestiuni.nume_gestiune,cgest]
				.RowSourceType	= 6
				.Sorted = .F.
			Endwith
		Endif
		
	ENDPROC

	PROCEDURE Show
		Lparameters nStyle
		This.ct_grid_search1.initializare(.T.)
		
	ENDPROC

	PROCEDURE Ct_grid_search1.Cb_tx_gestout._cbbase1.Valid
		SELECT nom_gestiuni
		*!*	pcobj.id_gestout = id_GESTiune
		*!*	pcobj.gestout = nume_gestiune
		*!*	pcObj.cgest = cgest
		*!*	pcobj.id_GESTiune = id_GESTiune
		*!*	pcobj.nume_gestiune = nume_gestiune
		
		thisform.ct_GRID_SEARCH1.initializare(.t.)
		this.Parent.Parent.cb_tx_cautare1.text.SetFocus 
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_gv_cant AS frm_termin_renunt OF "_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtutilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtpolitica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDatai" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDataf" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_politica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbPerioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_utilizatori" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_politici" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: do_cauta2
		*p: cnumepol
		*p: cnumeutilizator
		*p: ctitlu
		*p: orezult
		*p: pddataf
		*p: pddatai
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cnumepol = 
		cnumeutilizator = 
		ctitlu = 
		DoCreate = .T.
		Height = 154
		Name = "frm_rap_gv_cant"
		orezult = 
		pddataf = {}
		pddatai = {}
		Width = 377
		_shape1.Name = "_shape1"
		_shape1.ZOrderSet = 2
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 65
		_shape2.ZOrderSet = 4
		Lb_titlu_alb_b121.Caption = "Alegeti felul raportului"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 8
		Lb_titlu_alb_b121.ZOrderSet = 5
		BUT_TERMIN1.Left = 345
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
		But_renunt1.Left = 315
		But_renunt1.Name = "But_renunt1"
		But_renunt1.TabIndex = 5
		But_renunt1.Top = 1
		But_renunt1.ZOrderSet = 7
	*</PropValue>

	ADD OBJECT '_txDataf' AS _textbox WITH ;
		ControlSource = "thisform.pddataf", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 108, ;
		Name = "_txDataf", ;
		TabIndex = 3, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txDatai' AS _textbox WITH ;
		ControlSource = "thisform.pddatai", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 24, ;
		Name = "_txDatai", ;
		TabIndex = 2, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtpolitica' AS _textbox WITH ;
		ControlSource = "thisform.cnumepol", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtpolitica", ;
		TabIndex = 10, ;
		Top = 280, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtutilizator' AS _textbox WITH ;
		ControlSource = "thisform.cnumeutilizator", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtutilizator", ;
		TabIndex = 9, ;
		Top = 195, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		Left = 327, ;
		Name = "But_cautare1", ;
		TabIndex = 14, ;
		Top = 191, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_cautare2' AS but_cautare WITH ;
		caction = do_cauta2, ;
		Left = 327, ;
		Name = "But_cautare2", ;
		TabIndex = 15, ;
		Top = 276, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'lb_politica' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Politica de preturi", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 20, ;
		Name = "lb_politica", ;
		TabIndex = 11, ;
		Top = 237, ;
		Width = 88, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lb_utilizator' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Utilizatori", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 15, ;
		Name = "lb_utilizator", ;
		TabIndex = 12, ;
		Top = 152, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbPerioada' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Perioada", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 17, ;
		Name = "lbPerioada", ;
		TabIndex = 13, ;
		Top = 74, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'opt_politici' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_politici", ;
		TabIndex = 7, ;
		Top = 256, ;
		Option1.Caption = "Toate", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Politica", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

	ADD OBJECT 'opt_utilizatori' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_utilizatori", ;
		TabIndex = 6, ;
		Top = 173, ;
		Option1.Caption = "Toti", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Utilizator", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

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

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 7, ;
		Name = "Shape2", ;
		Top = 247, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 9, ;
		Name = "Shape3", ;
		Top = 84, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE do_cauta
		If Thisform.opt_utilizatori.Value=2
			pcselect = [select distinct utilizator from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [Utilizator]
			pcTitlu = [Utilizator]
			pcTitluColoane = [Utilizator]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.utilizator)
				Thisform.cnumeutilizator=locauta.utilizator
				Thisform._txtutilizator.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE do_cauta2
		If Thisform.opt_politici.Value=2
			pcselect = [select distinct nume_lista_preturi from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [nume_lista_preturi]
			pcTitlu = [Politica de preturi]
			pcTitluColoane = [Politica de preturi]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.nume_lista_preturi)
				Thisform.cnumepol=locauta.nume_lista_preturi
				Thisform._txtpolitica.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE inainte_de_do_termin
		PRIVATE pdDataI, pdDataF
		pdDataI = THISFORM.pdDataI
		pdDataF = THISFORM.pdDataF
		
		DO CASE
			CASE EMPTY(THISFORM.pdDataI)
				amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			CASE EMPTY(THISFORM.pdDataF)
				amessagebox("Nu ati completat data finala!",0+48,"Atentie")
				THISFORM._txDataf.SETFOCUS()
			CASE THISFORM.pdDataI>THISFORM.pdDataF
				amessagebox("Data initiala trebuie sa fie mai mica decat data finala a raportului!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			OTHERWISE
				PRIVATE pcschema,pcselect,pcfiltru,pcorder,pcgroup,poLista
				STORE '' TO poLista
				lnUtil=THISFORM.opt_utilizatori.VALUE
				lnPol=THISFORM.opt_politici.VALUE
		
				****
				lcSel = [{call pack_gest_vanzari.vanzari(?pdDataI, ?pdDataF, ?gnIdSucursala)}]
				lcCursor = 'cweb_vanzari'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.vanzari' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
				
				&& produsele care apar in mai multe liste de preturi
				SELECT id_articol, CNT(id_articol) AS CNT ;
					FROM cweb_vanzari ;
					GROUP BY 1 ;
					ORDER BY 2 ;
					HAVING CNT > 1 ;
					INTO CURSOR cMultiListe
		
				PRIVATE pcId_produse
				STORE '' TO pcId_produse
		
				SELECT cweb_vanzari
				SCAN
					pcId_produse = pcId_produse + ALLTRIM(STR(id_articol)) + ","
					SELECT cweb_vanzari
				ENDSCAN
		
				IF pcId_produse <> ","
					pcId_produse = SUBSTR(pcId_produse,1,LEN(pcId_produse)-1)
				ENDIF
				***--------
				lcSel = [{call pack_gest_vanzari.vanzari_comparativ(?pcId_produse)}]
				lcCursor = 'cweb_vanzari_retetar_o'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.vanzari_comparativ' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				lcSel = [{call pack_gest_vanzari.scazut_gest(?gnAn, ?gnLuna, ?pdDataI, ?pdDataF, ?gnIdSucursala)}]
				lcCursor = 'cScazut_gest'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.scazut_gest' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				SELECT s2.id_material, s2.denumire, ;
					s2.um, ;
					SUM(ROUND(s2.cant_mat* s1.cant_vand,gnPCant)) AS cant_nec ;
					FROM cweb_vanzari_retetar_o s2 ;
					LEFT JOIN cweb_vanzari s1 ON s1.id_articol = s2.id_produs ;
					GROUP BY s2.id_material, s2.denumire, s2.um ;
					INTO CURSOR cweb_retetar
		
				SELECT * FROM cscazut_gest ;
					WHERE CONT = '301' ;
					INTO CURSOR cscazut_gest301
		
				SELECT IIF(EMPTY(NVL(r.denumire,SPACE(30))),g.denumire,r.denumire) AS denumire, ;
					NVL(r.cant_nec, 0) AS cant_nec, ;
					NVL(g.cante,0) AS cante, ;
					ROUND(NVL(r.cant_nec, 0) - NVL(g.cante,0),gnPCant) AS DIF, ;
					IIF(EMPTY(NVL(r.um, SPACE(10))), g.um,r.um) AS um, ;
					IIF(ISNULL(r.id_material),1,0) AS adaugat ;
					FROM cweb_retetar r ;
					FULL JOIN cscazut_gest301 g ;
					ON r.id_material = g.id_articol ;
					ORDER BY 6,1 ;
					INTO CURSOR cweb_vanzari_retetar
		
				SELECT *, 00000000 AS id_pol, ;
					SPACE(30) AS nume_lista_preturi, ;
					00000000000.000 AS cant_vand, ;
					0 AS vanzari ;
					FROM cweb_vanzari_retetar ;
					INTO CURSOR cListComp_1 READWRITE
		
				SELECT * FROM cscazut_gest ;
					WHERE CONT = '371' ;
					INTO CURSOR cscazut_gest371
			
			
				SELECT NVL(v.id_articol, g.id_articol) AS id_articol, ;
					NVL(v.denumire, g.denumire) AS denumire, ;
					NVL(v.codmat,'') AS codmat, ;
					NVL(v.um, g.um) AS um, ;
					NVL(v.cant_vand, 0) AS cant_vand, ;
					NVL(v.id_pol,0) AS id_pol, ;
					NVL(v.nume_lista_preturi, '') AS nume_lista_preturi, ;
					NVL(pretvtva,0.00) AS pretvtva, ;
					NVL(proc_tvav,0.00) AS proc_tvav, ;
					NVL(valoare,0.00) AS valoare, ;
					NVL(g.cante,0.00) AS cante, ;
					ROUND(NVL(v.cant_vand, 0) - NVL(g.cante,0),gnPCant) AS DIF, ;
					1 AS vanzari ;
					FROM cweb_vanzari v ;
					FULL JOIN cscazut_gest371 g ;
					ON v.id_articol = g.id_articol ;
					INTO CURSOR cVanz READWRITE 
					
				&& las cantitatea scazuta doar pe prima lista	
				SELECT cMultiListe	
				SCAN
					lnId_articol = id_articol
					gnCount = 0
					SELECT cVanz
					LOCATE FOR id_articol = lnId_articol 
					DO WHILE FOUND( )
					   gnCount = gnCount + 1
					   IF gnCount > 1
					  	 REPLACE cante WITH 0, dif WITH cant_vand - cante
					   ENDIF 
					   CONTINUE
					ENDDO
		
				SELECT cMultiListe		
				ENDSCAN	
		
				SELECT cListComp_1
				APPEND FROM DBF("cVanz")
		
				IF USED("cVanz")
					USE IN cVanz
				ENDIF
		
				SELECT * FROM cListComp_1 ;
					ORDER BY vanzari DESC, nume_lista_preturi, id_pol, denumire INTO CURSOR cListComp  
				
				IF USED("cListComp_1")
					USE IN cListComp_1
				ENDIF
		
				pcTitlu = THISFORM.ctitlu
				pcPerioada = "Perioada: " + DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
		
		*!*	modificare	18.02.2008
		*!*			pcDataora = get_Ora(2)
		*!*			SELECT cListComp
		*!*			THISFORM.ALWAYSONTOP = .F.
		*!*			REPORT FORM rap_vanzari_comp_cant.frx TO PRINTER PROMPT PREVIEW
		*!*			THISFORM.ALWAYSONTOP = .T.
			THISFORM.ALWAYSONTOP = .F.
			goExport.export2frx([cListComp],[rap_vanzari_comp_cant])
			THISFORM.ALWAYSONTOP = .T.
		*!*	modificare	18.02.2008	^
		
				****
				*!*			pcschema=[]
				*!*			pcselect=[select utilizator,nume_lista_preturi,denumire,um,pret,]+;
				*!*				[SUM(cantitate) as cantitate from ]+gcS+[.vvanzari_detalii where 1=2]
				*!*			pcfiltru=[trunc(dataora) between to_date(']+DTOS(THISFORM.pdDataI)+[','YYYYMMDD') and ]+;
				*!*				[to_date(']+DTOS(THISFORM.pdDataF)+[','YYYYMMDD') ]+;
				*!*				IIF(lnUtil=2,[ and utilizator=']+UPPER(ALLTRIM(THISFORM.cnumeutilizator))+['],[])+;
				*!*				IIF(lnPol=2,[ and nume_lista_preturi=']+UPPER(ALLTRIM(THISFORM.cnumepol))+['],[])
				*!*			pcorder=[utilizator,nume_lista_preturi,denumire,um,pret]
				*!*			pcgroup=[utilizator,nume_lista_preturi,denumire,um,pret]
				*!*			llAfiseaza=.F.
				*!*			gencursor('polista','crsmarfuri',pcselect,pcfiltru,pcschema,pcorder,llAfiseaza,pcgroup)
				*!*			poLista.ca_baza1.afisare()
				*!*			pcTitlu = THISFORM.ctitlu
				*!*			pcPerioada = DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
				*!*			pcDataora = get_Ora(2)
		
				*!*			SELECT crsmarfuri
				*!*			THISFORM.ALWAYSONTOP=.F.
				*!*			REPORT FORMAT rap_marfuri_lista TO PRINTER PROMPT NOCONSOLE PREVIEW
				*!*			THISFORM.ALWAYSONTOP=.T.
				*!*			USE IN crsmarfuri
		
		ENDCASE
		
		IF USED("cWeb_vanzari")
			USE IN cweb_vanzari
		ENDIF
		
		IF USED("cScazut_gest")
			USE IN cscazut_gest
		ENDIF
		
		IF USED("cScazut_gest371")
			USE IN cscazut_gest371
		ENDIF
		
		IF USED("cWeb_vanzari_retetar_o")
			USE IN cweb_vanzari_retetar_o
		ENDIF
		
		IF USED("cWeb_retetar")
			USE IN cweb_retetar
		ENDIF
		
		IF USED("cWeb_vanzari_retetar")
			USE IN cweb_vanzari_retetar
		ENDIF
		
		IF USED("cListComp")
			USE IN cListComp
		ENDIF
		
		
		RETURN .F.
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.ctitlu = [RAPORT COMPARATIV DE SCADERE DIN GESTIUNE PE BAZA DE FISA TEHNOLOGICA]
		pdDataOra=get_ora()
		this.pddatai = TTOD(pdDataOra)
		this.pddataf = TTOD(pdDataOra)
	ENDPROC

	PROCEDURE opt_politici.Click
		If This.Value=1
			Thisform._txtpolitica.Value=[]
			Thisform.but_cautare2.Visible=.F.
		Else
			Thisform.but_cautare2.Visible=.T.
		Endif
	ENDPROC

	PROCEDURE opt_utilizatori.Click
		If This.Value=1
			Thisform._txtutilizator.Value=[]
			Thisform.but_cautare1.Visible=.F.
		Else
			Thisform.but_cautare1.Visible=.T.
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_gv_cant_4cat AS frm_termin_renunt OF "_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDataf" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDatai" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtpolitica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtutilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbPerioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_politica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_utilizatori" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_politici" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: do_cauta2
		*p: cnumepol
		*p: cnumeutilizator
		*p: ctitlu
		*p: orezult
		*p: pddataf
		*p: pddatai
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cnumepol = 
		cnumeutilizator = 
		ctitlu = 
		DoCreate = .T.
		Height = 154
		Name = "frm_rap_gv_cant_4cat"
		orezult = 
		pddataf = {}
		pddatai = {}
		Width = 377
		_shape1.Name = "_shape1"
		_shape1.ZOrderSet = 2
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 65
		_shape2.ZOrderSet = 4
		Lb_titlu_alb_b121.Caption = "Alegeti felul raportului"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 8
		Lb_titlu_alb_b121.ZOrderSet = 5
		BUT_TERMIN1.Left = 345
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
		But_renunt1.Left = 315
		But_renunt1.Name = "But_renunt1"
		But_renunt1.TabIndex = 5
		But_renunt1.Top = 1
		But_renunt1.ZOrderSet = 7
	*</PropValue>

	ADD OBJECT '_txDataf' AS _textbox WITH ;
		ControlSource = "thisform.pddataf", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 108, ;
		Name = "_txDataf", ;
		TabIndex = 3, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txDatai' AS _textbox WITH ;
		ControlSource = "thisform.pddatai", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 24, ;
		Name = "_txDatai", ;
		TabIndex = 2, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtpolitica' AS _textbox WITH ;
		ControlSource = "thisform.cnumepol", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtpolitica", ;
		TabIndex = 10, ;
		Top = 280, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtutilizator' AS _textbox WITH ;
		ControlSource = "thisform.cnumeutilizator", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtutilizator", ;
		TabIndex = 9, ;
		Top = 195, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		Left = 327, ;
		Name = "But_cautare1", ;
		TabIndex = 14, ;
		Top = 191, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_cautare2' AS but_cautare WITH ;
		caction = do_cauta2, ;
		Left = 327, ;
		Name = "But_cautare2", ;
		TabIndex = 15, ;
		Top = 276, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'lb_politica' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Politica de preturi", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 20, ;
		Name = "lb_politica", ;
		TabIndex = 11, ;
		Top = 237, ;
		Width = 88, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lb_utilizator' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Utilizatori", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 15, ;
		Name = "lb_utilizator", ;
		TabIndex = 12, ;
		Top = 152, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbPerioada' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Perioada", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 17, ;
		Name = "lbPerioada", ;
		TabIndex = 13, ;
		Top = 74, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'opt_politici' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_politici", ;
		TabIndex = 7, ;
		Top = 256, ;
		Option1.Caption = "Toate", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Politica", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

	ADD OBJECT 'opt_utilizatori' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_utilizatori", ;
		TabIndex = 6, ;
		Top = 173, ;
		Option1.Caption = "Toti", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Utilizator", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

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

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 7, ;
		Name = "Shape2", ;
		Top = 247, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 9, ;
		Name = "Shape3", ;
		Top = 84, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE do_cauta
		If Thisform.opt_utilizatori.Value=2
			pcselect = [select distinct utilizator from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [Utilizator]
			pcTitlu = [Utilizator]
			pcTitluColoane = [Utilizator]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.utilizator)
				Thisform.cnumeutilizator=locauta.utilizator
				Thisform._txtutilizator.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE do_cauta2
		If Thisform.opt_politici.Value=2
			pcselect = [select distinct nume_lista_preturi from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [nume_lista_preturi]
			pcTitlu = [Politica de preturi]
			pcTitluColoane = [Politica de preturi]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.nume_lista_preturi)
				Thisform.cnumepol=locauta.nume_lista_preturi
				Thisform._txtpolitica.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE inainte_de_do_termin
		PRIVATE pdDataI, pdDataF
		pdDataI = THISFORM.pdDataI
		pdDataF = THISFORM.pdDataF
		
		DO CASE
			CASE EMPTY(THISFORM.pdDataI)
				amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			CASE EMPTY(THISFORM.pdDataF)
				amessagebox("Nu ati completat data finala!",0+48,"Atentie")
				THISFORM._txDataf.SETFOCUS()
			CASE THISFORM.pdDataI>THISFORM.pdDataF
				amessagebox("Data initiala trebuie sa fie mai mica decat data finala a raportului!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			OTHERWISE
				PRIVATE pcschema,pcselect,pcfiltru,pcorder,pcgroup,poLista
				STORE '' TO poLista
				lnUtil=THISFORM.opt_utilizatori.VALUE
				lnPol=THISFORM.opt_politici.VALUE
		
				****
				lcSel = [{call pack_gest_vanzari.vanzari(?pdDataI, ?pdDataF, ?gnIdSucursala)}]
				lcCursor = 'cweb_vanzari'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.vanzari' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				&& produsele care apar in mai multe liste de preturi
				SELECT id_articol, CNT(id_articol) AS CNT ;
					FROM cweb_vanzari ;
					GROUP BY 1 ;
					ORDER BY 2 ;
					HAVING CNT > 1 ;
					INTO CURSOR cMultiListe
		
				PRIVATE pcId_produse
				STORE '' TO pcId_produse
		
				SELECT cweb_vanzari
				SCAN
					pcId_produse = pcId_produse + ALLTRIM(STR(id_articol)) + ","
					SELECT cweb_vanzari
				ENDSCAN
		
				IF pcId_produse <> ","
					pcId_produse = SUBSTR(pcId_produse,1,LEN(pcId_produse)-1)
				ENDIF
				***--------
				lcSel = [{call pack_gest_vanzari.vanzari_comparativ(?pcId_produse)}]
				lcCursor = 'cweb_vanzari_retetar_o'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.vanzari_comparativ' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				lcSel = [{call pack_gest_vanzari.scazut_gest(?gnAn, ?gnLuna, ?pdDataI, ?pdDataF, ?gnIdSucursala)}]
				lcCursor = 'cScazut_gest'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.scazut_gest' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				SELECT s2.id_material, s2.denumire, ;
					s2.um, ;
					SUM(ROUND(s2.cant_mat* s1.cant_vand,gnPCant)) AS cant_nec ;
					FROM cweb_vanzari_retetar_o s2 ;
					LEFT JOIN cweb_vanzari s1 ON s1.id_articol = s2.id_produs ;
					GROUP BY s2.id_material, s2.denumire, s2.um ;
					INTO CURSOR cweb_retetar
		
				SELECT * FROM cscazut_gest ;
					WHERE CONT = '301' ;
					INTO CURSOR cscazut_gest301
		
				SELECT IIF(EMPTY(NVL(r.denumire,SPACE(30))),g.denumire,r.denumire) AS denumire, ;
					NVL(r.cant_nec, 0) AS cant_nec, ;
					NVL(g.cante,0) AS cante, ;
					ROUND(NVL(r.cant_nec, 0) - NVL(g.cante,0),gnPCant) AS DIF, ;
					IIF(EMPTY(NVL(r.um, SPACE(10))), g.um,r.um) AS um, ;
					IIF(ISNULL(r.id_material),1,0) AS adaugat ;
					FROM cweb_retetar r ;
					FULL JOIN cscazut_gest301 g ;
					ON r.id_material = g.id_articol ;
					ORDER BY 6,1 ;
					INTO CURSOR cweb_vanzari_retetar
		
				SELECT *, 00000000 AS id_pol, ;
					SPACE(30) AS nume_lista_preturi, ;
					00000000000.000 AS cant_vand, ;
					0 AS vanzari ;
					FROM cweb_vanzari_retetar ;
					INTO CURSOR cListComp_1 READWRITE
		
				SELECT * FROM cscazut_gest ;
					WHERE CONT = '371' ;
					INTO CURSOR cscazut_gest371
		
		
				SELECT NVL(v.id_articol, g.id_articol) AS id_articol, ;
					NVL(v.denumire, g.denumire) AS denumire, ;
					NVL(v.codmat,'') AS codmat, ;
					NVL(v.um, g.um) AS um, ;
					NVL(v.cant_vand, 0) AS cant_vand, ;
					NVL(v.id_pol,0) AS id_pol, ;
					NVL(v.nume_lista_preturi, '') AS nume_lista_preturi, ;
					NVL(pretvtva,0.00) AS pretvtva, ;
					NVL(proc_tvav,0.00) AS proc_tvav, ;
					NVL(valoare,0.00) AS valoare, ;
					NVL(g.cante,0.00) AS cante, ;
					ROUND(NVL(v.cant_vand, 0) - NVL(g.cante,0),gnPCant) AS DIF, ;
					1 AS vanzari ;
					FROM cweb_vanzari v ;
					FULL JOIN cscazut_gest371 g ;
					ON v.id_articol = g.id_articol ;
					INTO CURSOR cVanz READWRITE
		
				&& las cantitatea scazuta doar pe prima lista
				SELECT cMultiListe
				SCAN
					lnId_articol = id_articol
					gnCount = 0
					SELECT cVanz
					LOCATE FOR id_articol = lnId_articol
					DO WHILE FOUND( )
						gnCount = gnCount + 1
						IF gnCount > 1
							REPLACE cante WITH 0, DIF WITH cant_vand - cante
						ENDIF
						CONTINUE
					ENDDO
		
					SELECT cMultiListe
				ENDSCAN
		
				SELECT cListComp_1
				APPEND FROM DBF("cVanz")
		
				IF USED("cVanz")
					USE IN cVanz
				ENDIF
		
		
				pcTitlu = THISFORM.ctitlu
				pcPerioada = "Perioada: " + DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
		*!*			pcDataora = get_Ora(2)
		
				*!*			SELECT * FROM cListComp INTO TABLE c:\test.DBF
				*!*			SELECT cListComp
				*!*			BROWSE
		
				SELECT *, 0 AS categorie FROM cListComp_1 INTO CURSOR cListComp READWRITE
		
				IF USED("cListComp_1")
					USE IN cListComp_1
				ENDIF
		
				SELECT cListComp
				REPLACE ALL categorie WITH 1 FOR vanzari = 0 AND DIF = 0
				REPLACE ALL categorie WITH 2 FOR vanzari = 0 AND DIF <> 0 AND cant_nec <> 0 AND cante <> 0
				REPLACE ALL categorie WITH 3 FOR vanzari = 0 AND DIF <> 0 AND cant_nec = 0 AND cante <> 0
				REPLACE ALL categorie WITH 4 FOR vanzari = 0 AND DIF <> 0 AND cant_nec <> 0 AND cante = 0
		
				PRIVATE pcCateg1, pccateg2, pccateg3, pccateg4
				pcCateg1 = 'Articole care trebuiau consumate si s-au consumat in cantitati corecte'
				pccateg2 = 'Articole care trebuiau consumate si s-au consumat in cantitati cu diferente'
				pccateg3 = 'Articole consumate care nu erau pe retete'
				pccateg4 = 'Articole care erau pe retete dar nu s-au consumat'
		
		
				SELECT * FROM cListComp ORDER BY vanzari DESC, categorie, nume_lista_preturi, id_pol, denumire ;
					INTO CURSOR cListez
		
		
		*!*			SELECT cListez
		*!*			THISFORM.ALWAYSONTOP = .F.
		*!*			REPORT FORM rap_vanzari_comp_cant_4cat.frx TO PRINTER PROMPT PREVIEW
		*!*			THISFORM.ALWAYSONTOP = .T.
				Thisform.AlwaysOnTop=.F.
				goExport.export2frx([cListez],[rap_vanzari_comp_cant_4cat])
				Thisform.AlwaysOnTop=.T.
				****
				*!*			pcschema=[]
				*!*			pcselect=[select utilizator,nume_lista_preturi,denumire,um,pret,]+;
				*!*				[SUM(cantitate) as cantitate from ]+gcS+[.vvanzari_detalii where 1=2]
				*!*			pcfiltru=[trunc(dataora) between to_date(']+DTOS(THISFORM.pdDataI)+[','YYYYMMDD') and ]+;
				*!*				[to_date(']+DTOS(THISFORM.pdDataF)+[','YYYYMMDD') ]+;
				*!*				IIF(lnUtil=2,[ and utilizator=']+UPPER(ALLTRIM(THISFORM.cnumeutilizator))+['],[])+;
				*!*				IIF(lnPol=2,[ and nume_lista_preturi=']+UPPER(ALLTRIM(THISFORM.cnumepol))+['],[])
				*!*			pcorder=[utilizator,nume_lista_preturi,denumire,um,pret]
				*!*			pcgroup=[utilizator,nume_lista_preturi,denumire,um,pret]
				*!*			llAfiseaza=.F.
				*!*			gencursor('polista','crsmarfuri',pcselect,pcfiltru,pcschema,pcorder,llAfiseaza,pcgroup)
				*!*			poLista.ca_baza1.afisare()
				*!*			pcTitlu = THISFORM.ctitlu
				*!*			pcPerioada = DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
				*!*			pcDataora = get_Ora(2)
		
				*!*			SELECT crsmarfuri
				*!*			THISFORM.ALWAYSONTOP=.F.
				*!*			REPORT FORMAT rap_marfuri_lista TO PRINTER PROMPT NOCONSOLE PREVIEW
				*!*			THISFORM.ALWAYSONTOP=.T.
				*!*			USE IN crsmarfuri
		
		ENDCASE
		
		IF USED("cWeb_vanzari")
			USE IN cweb_vanzari
		ENDIF
		
		IF USED("cScazut_gest")
			USE IN cscazut_gest
		ENDIF
		
		IF USED("cScazut_gest371")
			USE IN cscazut_gest371
		ENDIF
		
		IF USED("cWeb_vanzari_retetar_o")
			USE IN cweb_vanzari_retetar_o
		ENDIF
		
		IF USED("cWeb_retetar")
			USE IN cweb_retetar
		ENDIF
		
		IF USED("cWeb_vanzari_retetar")
			USE IN cweb_vanzari_retetar
		ENDIF
		
		IF USED("cListComp")
			USE IN cListComp
		ENDIF
		
		IF USED("cListez")
			USE IN cListez
		ENDIF
		
		RETURN .F.
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.ctitlu = [RAPORT COMPARATIV DE SCADERE DIN GESTIUNE PE BAZA DE FISA TEHNOLOGICA]
		pdDataOra=get_ora()
		this.pddatai = TTOD(pdDataOra)
		this.pddataf = TTOD(pdDataOra)
	ENDPROC

	PROCEDURE opt_politici.Click
		If This.Value=1
			Thisform._txtpolitica.Value=[]
			Thisform.but_cautare2.Visible=.F.
		Else
			Thisform.but_cautare2.Visible=.T.
		Endif
	ENDPROC

	PROCEDURE opt_utilizatori.Click
		If This.Value=1
			Thisform._txtutilizator.Value=[]
			Thisform.but_cautare1.Visible=.F.
		Else
			Thisform.but_cautare1.Visible=.T.
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_gv_val AS frm_termin_renunt OF "_frm_child.vcx" 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtutilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txtpolitica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDatai" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_txDataf" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_cautare2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_politica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbPerioada" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_utilizatori" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_politici" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: do_cauta2
		*p: cnumepol
		*p: cnumeutilizator
		*p: ctitlu
		*p: orezult
		*p: pddataf
		*p: pddatai
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cnumepol = 
		cnumeutilizator = 
		ctitlu = 
		DoCreate = .T.
		Height = 156
		Name = "frm_rap_gv_val"
		orezult = 
		pddataf = {}
		pddatai = {}
		Width = 377
		_shape1.Name = "_shape1"
		_shape1.ZOrderSet = 2
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 65
		_shape2.ZOrderSet = 4
		Lb_titlu_alb_b121.Caption = "Alegeti felul raportului"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 8
		Lb_titlu_alb_b121.ZOrderSet = 5
		BUT_TERMIN1.Left = 345
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
		But_renunt1.Left = 315
		But_renunt1.Name = "But_renunt1"
		But_renunt1.TabIndex = 5
		But_renunt1.Top = 1
		But_renunt1.ZOrderSet = 7
	*</PropValue>

	ADD OBJECT '_txDataf' AS _textbox WITH ;
		ControlSource = "thisform.pddataf", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 108, ;
		Name = "_txDataf", ;
		TabIndex = 3, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txDatai' AS _textbox WITH ;
		ControlSource = "thisform.pddatai", ;
		DisabledForeColor = 0,0,0, ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 24, ;
		Name = "_txDatai", ;
		TabIndex = 2, ;
		Top = 108, ;
		Width = 72, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtpolitica' AS _textbox WITH ;
		ControlSource = "thisform.cnumepol", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtpolitica", ;
		TabIndex = 10, ;
		Top = 280, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT '_txtutilizator' AS _textbox WITH ;
		ControlSource = "thisform.cnumeutilizator", ;
		DisabledForeColor = 0,0,0, ;
		Enabled = .F., ;
		FontItalic = .T., ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Height = 22, ;
		Left = 111, ;
		Name = "_txtutilizator", ;
		TabIndex = 9, ;
		Top = 195, ;
		Width = 215, ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'But_cautare1' AS but_cautare WITH ;
		Left = 327, ;
		Name = "But_cautare1", ;
		TabIndex = 14, ;
		Top = 191, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_cautare2' AS but_cautare WITH ;
		caction = do_cauta2, ;
		Left = 327, ;
		Name = "But_cautare2", ;
		TabIndex = 15, ;
		Top = 276, ;
		Visible = .F.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'lb_politica' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Politica de preturi", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 20, ;
		Name = "lb_politica", ;
		TabIndex = 11, ;
		Top = 237, ;
		Width = 88, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lb_utilizator' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Utilizatori", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 15, ;
		Name = "lb_utilizator", ;
		TabIndex = 12, ;
		Top = 152, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbPerioada' AS label WITH ;
		Alignment = 2, ;
		BackColor = 255,255,255, ;
		Caption = "Perioada", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 17, ;
		Name = "lbPerioada", ;
		TabIndex = 13, ;
		Top = 74, ;
		Width = 63, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'opt_politici' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_politici", ;
		TabIndex = 7, ;
		Top = 256, ;
		Option1.Caption = "Toate", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Politica", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

	ADD OBJECT 'opt_utilizatori' AS _optiongrup WITH ;
		BorderStyle = 0, ;
		Left = 20, ;
		Name = "opt_utilizatori", ;
		TabIndex = 6, ;
		Top = 173, ;
		Option1.Caption = "Toti", ;
		Option1.FontName = "Arial Narrow", ;
		Option1.FontSize = 10, ;
		Option1.Left = 5, ;
		Option1.Name = "Option1", ;
		Option1.Top = 5, ;
		Option2.Caption = "Utilizator", ;
		Option2.FontName = "Arial Narrow", ;
		Option2.FontSize = 10, ;
		Option2.Left = 5, ;
		Option2.Name = "Option2", ;
		Option2.Top = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

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

	ADD OBJECT 'Shape2' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 7, ;
		Name = "Shape2", ;
		Top = 247, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'Shape3' AS shape WITH ;
		BackStyle = 0, ;
		Height = 66, ;
		Left = 9, ;
		Name = "Shape3", ;
		Top = 84, ;
		Width = 360, ;
		ZOrderSet = 1
		*< END OBJECT: BaseClass="shape" />
	
	PROCEDURE do_cauta
		If Thisform.opt_utilizatori.Value=2
			pcselect = [select distinct utilizator from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [Utilizator]
			pcTitlu = [Utilizator]
			pcTitluColoane = [Utilizator]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.utilizator)
				Thisform.cnumeutilizator=locauta.utilizator
				Thisform._txtutilizator.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE do_cauta2
		If Thisform.opt_politici.Value=2
			pcselect = [select distinct nume_lista_preturi from vvanzari_detalii]
			pcfiltru = [1=2]
			pcschema = []
			pcorder = [1]
			pccoloane = [nume_lista_preturi]
			pcTitlu = [Politica de preturi]
			pcTitluColoane = [Politica de preturi]
			locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,"")		&& 11.07.2007
			If !Empty(locauta.nume_lista_preturi)
				Thisform.cnumepol=locauta.nume_lista_preturi
				Thisform._txtpolitica.Refresh
			Endif
		Endif
	ENDPROC

	PROCEDURE inainte_de_do_termin
		PRIVATE pdDataI, pdDataF
		pdDataI = THISFORM.pdDataI
		pdDataF = THISFORM.pdDataF
		
		DO CASE
			CASE EMPTY(THISFORM.pdDataI)
				amessagebox("Nu ati completat data initiala!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			CASE EMPTY(THISFORM.pdDataF)
				amessagebox("Nu ati completat data finala!",0+48,"Atentie")
				THISFORM._txDataf.SETFOCUS()
			CASE THISFORM.pdDataI>THISFORM.pdDataF
				amessagebox("Data initiala trebuie sa fie mai mica decat data finala a raportului!",0+48,"Atentie")
				THISFORM._txDatai.SETFOCUS()
			OTHERWISE
				PRIVATE pcschema,pcselect,pcfiltru,pcorder,pcgroup,poLista
				STORE '' TO poLista
				lnUtil=THISFORM.opt_utilizatori.VALUE
				lnPol=THISFORM.opt_politici.VALUE
		
				****
				lcSel = [{call pack_gest_vanzari.vanzari(?pdDataI, ?pdDataF, ?gnIdSucursala)}]
				lcCursor = 'cweb_vanzari'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.vanzari' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
		
				***--------
				lcSel = [{call pack_gest_vanzari.scazut_gest_val(?gnAn, ?gnLuna, ?pdDataI, ?pdDataF,?gnIdSucursala)}]
				lcCursor = 'cScazut_gest'
				lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
				IF lnSucces < 0
					amessage('Call pack_gest_vanzari.scazut_gest_val' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
					RETURN
				ENDIF
			
				SELECT *, 00000000 AS id_pol, ;
					SPACE(30) AS nume_lista_preturi, ;
					00000000000.000 AS cant_vand, ;
					00000000000.000 AS pretvtva, ;
					0000000.000 AS proc_tvav, ;
					0 AS vanzari ;
					FROM cScazut_gest ;
					INTO CURSOR cListComp_1 READWRITE
		
				SELECT *, 1 AS vanzari FROM cweb_vanzari INTO CURSOR cVanz
		
				SELECT cListComp_1
				APPEND FROM DBF("cVanz")
		
				IF USED("cVanz")
					USE IN cVanz
				ENDIF
		
				SELECT * FROM cListComp_1 ;
					ORDER BY vanzari DESC, nume_lista_preturi, id_pol, cont, denumire INTO CURSOR cListComp
		
				IF USED("cListComp_1")
					USE IN cListComp_1
				ENDIF
				
				pcTitlu = THISFORM.ctitlu
				pcPerioada = "Perioada: " + DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
		*!*		modificare 18.02.2008
		*!*			pcDataora = get_Ora(2)	
		*!*			SELECT cListComp
		*!*			THISFORM.ALWAYSONTOP = .F.
		*!*			REPORT FORM rap_vanzari_comp_val.frx TO PRINTER PROMPT PREVIEW
		*!*			THISFORM.ALWAYSONTOP = .T.
				Thisform.AlwaysOnTop=.F.
				goExport.export2frx([cListComp],[rap_vanzari_comp_val])
				Thisform.AlwaysOnTop=.T.
		*!*		modificare 18.02.2008	^
				
				****
		*!*			pcschema=[]
		*!*			pcselect=[select utilizator,nume_lista_preturi,denumire,um,pret,]+;
		*!*				[SUM(cantitate) as cantitate from ]+gcS+[.vvanzari_detalii where 1=2]
		*!*			pcfiltru=[trunc(dataora) between to_date(']+DTOS(THISFORM.pdDataI)+[','YYYYMMDD') and ]+;
		*!*				[to_date(']+DTOS(THISFORM.pdDataF)+[','YYYYMMDD') ]+;
		*!*				IIF(lnUtil=2,[ and utilizator=']+UPPER(ALLTRIM(THISFORM.cnumeutilizator))+['],[])+;
		*!*				IIF(lnPol=2,[ and nume_lista_preturi=']+UPPER(ALLTRIM(THISFORM.cnumepol))+['],[])
		*!*			pcorder=[utilizator,nume_lista_preturi,denumire,um,pret]
		*!*			pcgroup=[utilizator,nume_lista_preturi,denumire,um,pret]
		*!*			llAfiseaza=.F.
		*!*			gencursor('polista','crsmarfuri',pcselect,pcfiltru,pcschema,pcorder,llAfiseaza,pcgroup)
		*!*			poLista.ca_baza1.afisare()
		*!*			pcTitlu = THISFORM.ctitlu
		*!*			pcPerioada = DTOC(THISFORM.pdDataI) + [ - ] + DTOC(THISFORM.pdDataF)
		*!*			pcDataora = get_Ora(2)
		
		*!*			SELECT crsmarfuri
		*!*			THISFORM.ALWAYSONTOP=.F.
		*!*			REPORT FORMAT rap_marfuri_lista TO PRINTER PROMPT NOCONSOLE PREVIEW
		*!*			THISFORM.ALWAYSONTOP=.T.
		*!*			USE IN crsmarfuri
		
		ENDCASE
		
		IF USED("cWeb_vanzari")
			USE IN cWeb_vanzari
		ENDIF
		
		IF USED("cScazut_gest")
			USE IN cScazut_gest
		ENDIF
		
		IF USED("cListComp")
			USE IN cListComp
		ENDIF 
		
		RETURN .F.
		
	ENDPROC

	PROCEDURE Show
		LPARAMETERS nStyle
		this.ctitlu = [RAPORT DE SCADERE DIN GESTIUNE]
		pdDataOra=get_ora()
		this.pddatai = TTOD(pdDataOra)
		this.pddataf = TTOD(pdDataOra)
	ENDPROC

	PROCEDURE opt_politici.Click
		If This.Value=1
			Thisform._txtpolitica.Value=[]
			Thisform.but_cautare2.Visible=.F.
		Else
			Thisform.but_cautare2.Visible=.T.
		Endif
	ENDPROC

	PROCEDURE opt_utilizatori.Click
		If This.Value=1
			Thisform._txtutilizator.Value=[]
			Thisform.but_cautare1.Visible=.F.
		Else
			Thisform.but_cautare1.Visible=.T.
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_reteta 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="grid_reteta" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_reteta.Column6.Text1" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<PropValue>
		cgridsortlist = grid_reteta
		DoCreate = .T.
		Height = 304
		Name = "frm_reteta"
		Width = 372
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 438
		_shape2.Left = 322
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		Lb_titlu_alb_b121.Caption = "Fise tehnologice"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		BUT_TERMIN1.Left = 342
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 204
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 5
	*</PropValue>

	ADD OBJECT 'grid_reteta' AS _grdrow WITH ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 255, ;
		Left = 8, ;
		Name = "grid_reteta", ;
		Panel = 1, ;
		RecordSource = "crsReteta", ;
		Top = 38, ;
		Width = 356, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "codmat_mat", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "Column2", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 41, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "denumire_mat", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "Column3", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 136, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "um_mat", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "Column4", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 49, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "cont_mat", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Name = "Column5", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 36, ;
		Column5.ColumnOrder = 3, ;
		Column5.ControlSource = "cant_mat", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,4)), ;
		Column5.Name = "Column6", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 58
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_reteta.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod material", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_reteta.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_reteta.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Unitate de masura", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_reteta.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cont", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_reteta.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

ENDDEFINE

DEFINE CLASS frm_vanzari 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="_shape3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column6.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column7.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column7.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column8.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column8.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column9.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_vanzari.Column9.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column6.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column7.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column7.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column8.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column8.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column9.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column9.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column10.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_detalii.Column10.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_reset1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_dataora" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtVanzari" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_sters" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDetalii" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_denumire" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_lucrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ck_numar_act" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: inainte_de_do_sterge2
		*p: ndetalii
		*p: nvanzari
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cgridsortlist = grid_vanzari,grid_detalii
		DoCreate = .T.
		Height = 588
		Name = "frm_vanzari"
		ndetalii = 0
		nvanzari = 0
		Width = 790
		WindowState = 2
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 791
		_shape1.ZOrderSet = 1
		_shape2.Anchor = 9
		_shape2.Left = 740
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.ZOrderSet = 2
		Lb_titlu_alb_b121.Caption = "Vanzari"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 760
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 4
		Gridsort1.Left = 192
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 6
	*</PropValue>

	ADD OBJECT '_shape3' AS _shape WITH ;
		Anchor = 10, ;
		BackStyle = 0, ;
		Height = 40, ;
		Left = 6, ;
		Name = "_shape3", ;
		Top = 35, ;
		Width = 744, ;
		ZOrderSet = 0
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="shape" />

	ADD OBJECT 'But_modifica1' AS but_modifica WITH ;
		Anchor = 9, ;
		Left = 755, ;
		Name = "But_modifica1", ;
		Top = 79, ;
		Visible = .T., ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'But_sterge2' AS but_sterge WITH ;
		Anchor = 12, ;
		caction = inainte_de_do_sterge2, ;
		Left = 755, ;
		Name = "But_sterge2", ;
		Top = 312, ;
		Visible = .T., ;
		ZOrderSet = 10
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ck_dataora' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		camp_nume = dataora, ;
		Caption = "Dataora introducerii", ;
		Left = 14, ;
		Name = "Ck_dataora", ;
		TabIndex = 3, ;
		tip = T, ;
		Top = 47, ;
		ZOrderSet = 14
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_denumire' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		camp_nume = denumire_part, ;
		Caption = "Partener", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		Left = 360, ;
		Name = "Ck_denumire", ;
		TabIndex = 7, ;
		Top = 47
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_lucrare' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		camp_nume = nrord, ;
		Caption = "Lucrare", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		Left = 297, ;
		Name = "Ck_lucrare", ;
		TabIndex = 17, ;
		Top = 47
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_numar_act' AS ck_filtru_numar WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		camp_nume = NUMAR_ACT, ;
		Caption = "Nr. act", ;
		FontName = "Arial Narrow", ;
		Left = 124, ;
		mask = (replicate('9',15)), ;
		Name = "Ck_numar_act", ;
		TabIndex = 4, ;
		Top = 47
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_sters' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "Sterse", ;
		Comment = "*:OnResize=LT", ;
		FontName = "Arial Narrow", ;
		ForeColor = 255,0,0, ;
		Height = 18, ;
		Left = 464, ;
		Name = "Ck_sters", ;
		TabIndex = 33, ;
		Top = 47, ;
		Width = 45, ;
		ZOrderSet = 18
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Ck_utilizator' AS ck_filtru_text WITH ;
		Alignment = 0, ;
		camp_nume = utilizator, ;
		Caption = "Operator introducere", ;
		FontCharSet = 238, ;
		FontName = "Arial Narrow", ;
		Left = 184, ;
		Name = "Ck_utilizator", ;
		TabIndex = 5, ;
		Top = 47, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 8, ;
		Left = 561, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 6, ;
		Top = 41, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_reset1' AS cmd_reset WITH ;
		Anchor = 8, ;
		Left = 657, ;
		Name = "Cmd_reset1", ;
		TabIndex = 16, ;
		Top = 41, ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grid_detalii' AS _grdrow WITH ;
		Anchor = 14, ;
		ColumnCount = 10, ;
		DeleteMark = .F., ;
		Height = 243, ;
		HighlightStyle = 2, ;
		Left = 6, ;
		Name = "grid_detalii", ;
		Panel = 1, ;
		RecordSource = "crsDetalii", ;
		Top = 312, ;
		Width = 744, ;
		ZOrderSet = 7, ;
		Column1.ControlSource = "nume_lista_preturi", ;
		Column1.Name = "Column1", ;
		Column1.Width = 98, ;
		Column2.ControlSource = "denumire", ;
		Column2.Name = "Column2", ;
		Column2.Width = 235, ;
		Column3.ControlSource = "cantitate", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(12,gnPCant)), ;
		Column3.Name = "Column3", ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "pret", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(12,gnPPretV)), ;
		Column4.Name = "Column4", ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "proc_tvav", ;
		Column5.Format = "rk", ;
		Column5.Name = "Column5", ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "diferenta", ;
		Column6.Format = "rk", ;
		Column6.InputMask = (get_mask(12,gnPPretV)), ;
		Column6.Name = "Column6", ;
		Column7.ColumnOrder = 8, ;
		Column7.ControlSource = "validat", ;
		Column7.Name = "Column7", ;
		Column8.ColumnOrder = 9, ;
		Column8.ControlSource = "utilizators", ;
		Column8.Name = "Column8", ;
		Column8.Width = 113, ;
		Column9.ColumnOrder = 10, ;
		Column9.ControlSource = "dataoras", ;
		Column9.Name = "Column9", ;
		Column9.Width = 103, ;
		Column10.ColumnOrder = 4, ;
		Column10.ControlSource = "um", ;
		Column10.Name = "Column10"
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_detalii.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Politica preturi", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column10.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Articol", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate ", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Proc tva", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Diferenta", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_detalii.Column7.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Validat", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

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

	ADD OBJECT 'grid_detalii.Column9.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Dataora stergerii", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_vanzari' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 9, ;
		DeleteMark = .F., ;
		Height = 197, ;
		HighlightStyle = 2, ;
		Left = 6, ;
		Name = "grid_vanzari", ;
		Panel = 1, ;
		RecordSource = "crsVanzari", ;
		Top = 81, ;
		Width = 744, ;
		ZOrderSet = 6, ;
		Column1.ControlSource = "dataora", ;
		Column1.Name = "Column1", ;
		Column1.Width = 133, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "utilizator", ;
		Column2.Name = "Column2", ;
		Column2.Width = 149, ;
		Column3.ColumnOrder = 6, ;
		Column3.ControlSource = "nr_persoane", ;
		Column3.Name = "Column3", ;
		Column3.Width = 84, ;
		Column4.ColumnOrder = 7, ;
		Column4.ControlSource = "nrinmat", ;
		Column4.Name = "Column4", ;
		Column4.Width = 98, ;
		Column5.ColumnOrder = 2, ;
		Column5.ControlSource = "numar_act", ;
		Column5.Name = "Column5", ;
		Column5.Width = 87, ;
		Column6.ColumnOrder = 4, ;
		Column6.ControlSource = "nrord", ;
		Column6.Name = "Column6", ;
		Column6.Width = 119, ;
		Column7.ColumnOrder = 5, ;
		Column7.ControlSource = "denumire_part", ;
		Column7.Name = "Column7", ;
		Column7.Width = 129, ;
		Column8.ControlSource = "utilizators", ;
		Column8.Name = "Column8", ;
		Column8.Width = 115, ;
		Column9.ControlSource = "dataoras", ;
		Column9.Name = "Column9", ;
		Column9.Width = 114
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_vanzari.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Dataora introducerii", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

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

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

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

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

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

	ADD OBJECT 'grid_vanzari.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Numar act", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_vanzari.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Lucrare", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_vanzari.Column7.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Partener", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

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

	ADD OBJECT 'grid_vanzari.Column9.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Dataora stergerii", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 12, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Total", ;
		Height = 17, ;
		Left = 575, ;
		Name = "Label1", ;
		Top = 285, ;
		Width = 29, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 12, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Total", ;
		Height = 17, ;
		Left = 575, ;
		Name = "Label2", ;
		Top = 563, ;
		Width = 29, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDetalii' AS textbox WITH ;
		Anchor = 12, ;
		ControlSource = "thisform.nDetalii", ;
		Format = "rk", ;
		Height = 23, ;
		InputMask = (get_mask(16,gnPA)), ;
		Left = 611, ;
		Name = "txtDetalii", ;
		ReadOnly = .T., ;
		Top = 560, ;
		Width = 139, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtVanzari' AS textbox WITH ;
		Anchor = 12, ;
		ControlSource = "thisform.nVanzari", ;
		Format = "rk", ;
		Height = 23, ;
		InputMask = (get_mask(16,gnPA)), ;
		Left = 611, ;
		Name = "txtVanzari", ;
		ReadOnly = .T., ;
		Top = 282, ;
		Width = 139, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE actualizeaza_grid1
		Lparameters lcFiltru
		If Empty(lcFiltru)
			lcFiltru = povanzari.ca_baza1.cfiltru
		Endif
		Thisform.MousePointer = 11
		Thisform.LockScreen = .T.
		save_grid_tag(Thisform.grid_vanzari)
		povanzari.ca_baza1.cfiltru = lcFiltru
		povanzari.ca_baza1.afisare()
		restore_grid_tag(Thisform.grid_vanzari)
		Thisform.LockScreen = .F.
		Thisform.MousePointer = 0
		If Reccount('crsVanzari')>0
			Thisform.grid_vanzari.SetFocus()
		Endif
	ENDPROC

	PROCEDURE actualizeaza_grid2
		Lparameters lcFiltru
		
		LOCAL lcFiltru2
		lcFiltru2 = lcFiltru
		
		IF thisform.ck_sters.Value = 1 
			*lcFiltru = lcFiltru + [ and 2=2 ] 
		ELSE
			lcFiltru2 = lcFiltru2 + [ and STERS=0] 
		ENDIF
		
		If Empty(lcFiltru)
			lcFiltru2 = poDetalii.ca_baza1.cfiltru
		Endif
		Thisform.MousePointer = 11
		Thisform.LockScreen = .T.
		save_grid_tag(Thisform.grid_detalii)
		poDetalii.ca_baza1.cfiltru = lcFiltru2
		poDetalii.ca_baza1.afisare()
		restore_grid_tag(Thisform.grid_detalii)
		
		SELECT crsDetalii
		CALCULATE SUM(ROUND(cantitate*pret-diferenta,gnPcant)) TO thisform.nDetalii
		thisform.txtDetalii.Refresh
		
		Thisform.LockScreen = .F.
		Thisform.MousePointer = 0
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		lcFiltru = [2=2]+gcCondSucursala
		
		If Thisform.ck_dataora.Value=1
			lcFiltru = lcFiltru + Thisform.ck_dataora.filtru
		ENDIF
		
		IF thisform.ck_numar_act.Value = 1
			lcFiltru = lcFiltru + Thisform.ck_numar_act.filtru
		ENDIF 
		
		If Thisform.ck_utilizator.Value=1
			lcFiltru = lcFiltru + Thisform.ck_utilizator.filtru
		ENDIF
		
		IF thisform.ck_lucrare.Value=1
			lcFiltru = lcFiltru + Thisform.ck_lucrare.filtru
		ENDIF
		
		IF thisform.ck_denumire.Value=1
			lcFiltru = lcFiltru + Thisform.ck_denumire.filtru
		ENDIF
		
		* inregistrari sterse
		IF thisform.ck_sters.Value = 1 
			*lcFiltru = lcFiltru + [ and 2=2 ] 
		ELSE
			lcFiltru = lcFiltru + [ and STERS=0] 
		ENDIF
		
		Thisform.actualizeaza_grid1(lcFiltru)
		
		&& adauc de pe server toate detaliile ca sa fac suma pt vanzarile cautate
		Thisform.actualizeaza_grid2(lcFiltru)
		SELECT crsDetalii
		CALCULATE SUM(ROUND(cantitate*pret-diferenta,gnPcant)) TO thisform.nVanzari 
		thisform.txtVanzari.Refresh 
		
		thisform.grid_vanzari.AfterRowColChange
		
		If Reccount('crsVanzari')=0
			amessagebox('Cautarea nu a intors rezultate!',0+48,'Info cautare')
			Thisform.ck_dataora.SetFocus()
		ENDIF
		
		
		
		
		
		
		
	ENDPROC

	PROCEDURE do_reset
		With Thisform
			For i=1 To .Objects.Count
				If Upper(.Objects(i).BaseClass)='CHECKBOX'
					.Objects(i).Value=0
				Endif
			Endfor
		Endwith
		Thisform.ck_dataora.SetFocus()
	ENDPROC

	PROCEDURE inainte_de_do_modifica
		IF RECCOUNT('crsVanzari')>0
			SELECT crsVanzari
			SCATTER NAME lorec
			lnId = lorec.id_vanzare
			DO Adauga_Modifica_Inregistrare WITH [vanzari],lorec,lnId,[UPDATE]
			IF gnButon = 1
				this.actualizeaza_grid1
			ENDIF
		ELSE
			aMESSAGEBOX("Nu sunt inregistrari de modificat!",0+48,"Atentie")
		ENDIF
		
	ENDPROC

	PROCEDURE inainte_de_do_sterge
		If Reccount('crsVanzari')>0
			Local loRec
			Select crsVanzari
			Scatter Name loRec
			Do STERGE_INREGISTRARE With "vanzari",loRec.id_vanzare
			This.actualizeaza_grid1()
		Endif
	ENDPROC

	PROCEDURE inainte_de_do_sterge2
		If Reccount('crsDetalii')>0
			Local loRec
			Select crsDetalii
			Scatter Name loRec
			Do STERGE_INREGISTRARE With "detalii",loRec.id_vanzare_det
			thisform.grid_vanzari.AfterRowColChange()
		Endif
	ENDPROC

	PROCEDURE Ck_sters.InteractiveChange
		*
	ENDPROC

	PROCEDURE grid_detalii.Init
		Thisform.grid_detalii.SetAll("DynamicForeColor", "IIF(sters=1, RGB(255,0,0), RGB(0,0,0))", "Column") 
	ENDPROC

	PROCEDURE grid_vanzari.AfterRowColChange
		Lparameters nColIndex
		If This.RowColChange<>2
			Local lnIdPol
			Select crsVanzari
			lnId_vanzare = id_vanzare
		*	lcData = DTOC(dataora)
			lcFiltru = [id_vanzare=]+Alltrim(Str(lnId_vanzare))
		
			Thisform.actualizeaza_grid2(lcFiltru)
			*Thisform.lb_detalii_politica.Caption="Detalii vanzarea "+Alltrim(lcNume)+" ( "+lcPerioada+" ) "
		Endif
	ENDPROC

	PROCEDURE grid_vanzari.Init
		Thisform.grid_vanzari.SetAll("DynamicForeColor", "IIF(sters=1, RGB(255,0,0), RGB(0,0,0))", "Column") 
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_vanzari_nou 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="Clb_datai" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_utilizator" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_image1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cus_odata_vanzari1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="BUT_RENUNT1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_lucrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_image2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_partener" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_image3" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: do_alege_lucrare
		*m: do_alege_partener
		*m: do_alege_utilizator
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 245
		Name = "frm_vanzari_nou"
		nid = 0
		orec = .F.
		Width = 375
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 313
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 60
		Lb_titlu_alb_b121.Caption = "Vanzari"
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 10
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 8
		BUT_TERMIN1.Top = 1
		Gridsort1.Left = 120
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 10
	*</PropValue>

	ADD OBJECT '_image1' AS _image WITH ;
		Height = 24, ;
		Left = 324, ;
		Name = "_image1", ;
		Picture = ..\..\..\roapreturi\comun\grafice\alege.bmp, ;
		Stretch = 2, ;
		ToolTipText = "Alegeti valuta", ;
		Top = 67, ;
		Width = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="image" />

	ADD OBJECT '_image2' AS _image WITH ;
		Height = 24, ;
		Left = 324, ;
		Name = "_image2", ;
		Picture = ..\..\..\roapreturi\comun\grafice\alege.bmp, ;
		Stretch = 2, ;
		ToolTipText = "Alegeti valuta", ;
		Top = 95, ;
		Width = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="image" />

	ADD OBJECT '_image3' AS _image WITH ;
		Height = 24, ;
		Left = 324, ;
		Name = "_image3", ;
		Picture = ..\..\..\roapreturi\comun\grafice\alege.bmp, ;
		Stretch = 2, ;
		ToolTipText = "Alegeti valuta", ;
		Top = 123, ;
		Width = 24
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="image" />

	ADD OBJECT 'BUT_RENUNT1' AS but_renunt WITH ;
		Left = 313, ;
		Name = "BUT_RENUNT1", ;
		TabIndex = 9, ;
		Top = 1
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_datai' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_datai", ;
		TabIndex = 1, ;
		Top = 39, ;
		Text_simplu1.ControlSource = "porec.dataora", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data ora", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_lucrare' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_lucrare", ;
		TabIndex = 3, ;
		TabStop = .T., ;
		ToolTipText = "Pentru modificare, faceti dublu-click!", ;
		Top = 95, ;
		Text_simplu1.Alignment = 1, ;
		Text_simplu1.ControlSource = "porec.nrord", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Lucrare", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_partener' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_partener", ;
		TabIndex = 4, ;
		TabStop = .T., ;
		ToolTipText = "Pentru modificare, faceti dublu-click!", ;
		Top = 123, ;
		Text_simplu1.Alignment = 1, ;
		Text_simplu1.ControlSource = "porec.denumire_part", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Partener", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu3' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_tx_simplu3", ;
		TabIndex = 5, ;
		Top = 151, ;
		Text_simplu1.ControlSource = "porec.numar_act", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Numar act", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu4' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_tx_simplu4", ;
		TabIndex = 6, ;
		Top = 179, ;
		Text_simplu1.ControlSource = "porec.nr_persoane", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Nr. persoane", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu5' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_tx_simplu5", ;
		TabIndex = 7, ;
		Top = 207, ;
		Text_simplu1.ControlSource = "porec.nrinmat", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Nr.inmat", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_utilizator' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_utilizator", ;
		TabIndex = 2, ;
		TabStop = .T., ;
		ToolTipText = "Pentru modificare, faceti dublu-click!", ;
		Top = 67, ;
		Text_simplu1.Alignment = 1, ;
		Text_simplu1.ControlSource = "porec.utilizator", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Utilizator", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Cus_odata_vanzari1' AS cus_odata_vanzari WITH ;
		Left = 246, ;
		Name = "Cus_odata_vanzari1", ;
		Top = 7
		*< END OBJECT: ClassLib="ointroduceri_web.vcx" BaseClass="custom" />
	
	PROCEDURE do_alege_lucrare
		LOCAL lcselect, lcfiltru, lcschema, lcorder, lccoloane, lcTitlu, lcTitluColoane, lcFiltruOriginal, lcNumeProc         
		lcselect = [select id_lucrare, nrord FROM vnom_lucrari ]
		lcfiltru = [1=2]
		lcschema = []
		lcorder = [nrord]
		lccoloane = [nrord]
		lcTitlu = [Alegeti lucrarea]
		lcTitluColoane = [Lucrare]
		lcFiltruOriginal = [inactiv = 0]
		lcNumeProc = ""
		locauta = cauta_alfa(lcselect, lcfiltru, lcschema, lcorder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, .F., lcFiltruOriginal)		&& 11.07.2007
		
		IF buton=2
			RETURN
		ENDIF 
		
		porec.id_lucrare = locauta.id_lucrare
		porec.nrord = locauta.nrord
		
		THISFORM.clb_lucrare.REFRESH()
	ENDPROC

	PROCEDURE do_alege_partener
		loCauta = caut_parteneri("4111","Clienti",.f.)
		IF buton=2
			RETURN
		ENDIF
		porec.id_part = locauta.id_part
		porec.denumire_part = locauta.denumire 
		thisform.clb_partener.Refresh 
	ENDPROC

	PROCEDURE do_alege_utilizator
		LOCAL lcselect, lcfiltru, lcschema, lcorder, lccoloane, lcTitlu, lcTitluColoane, lcFiltruOriginal, lcNumeProc         
		lcselect = [select id_util, utilizator FROM syn_vutilizatori ]
		lcfiltru = [1=2]
		lcschema = []
		lcorder = [utilizator]
		lccoloane = [utilizator]
		lcTitlu = [Alegeti utilizatorul]
		lcTitluColoane = [Utilizatori]
		lcFiltruOriginal = [inactiv = 0]
		lcNumeProc = ""
		locauta = cauta_alfa(lcselect, lcfiltru, lcschema, lcorder, lccoloane, lcTitlu, lcTitluColoane, lcNumeProc, .F., lcFiltruOriginal)		&& 11.07.2007
		
		IF buton=2
			RETURN
		ENDIF 
		
		poRec.id_util = IIF(!EMPTY(loCauta.id_util), loCauta.id_util, 0)
		poRec.utilizator = IIF(!EMPTY(loCauta.utilizator), loCauta.utilizator, "")
		
		THISFORM.clb_utilizator.REFRESH()
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local plReturn
		lccontrol = Upper(This.ActiveControl.BaseClass )
		If  Inlist(lccontrol,"TEXTBOX","EDITBOX","COMBOBOX")
			lcval=This.ActiveControl.ControlSource
			&lcval=Thisform.ActiveControl.Value
		Endif
		
		Do Case
		Case Empty(porec.dataora)
			amessagebox('Nu ati completat data/ora vanzarii!',0+48,"Atentie")
			This.clb_datai.text_simplu1.SetFocus()
			plReturn=.F.
		Case Empty(porec.id_util) Or Isnull(porec.id_util)
			amessagebox('Nu ati completat  utilizatorul!',0+48,"Atentie")
			This.clb_notaContab.text_simplu1.SetFocus()
			plReturn=.F.	
		Otherwise
			plReturn=This.cus_odata_vanzari1.salvare(This.OREC,This.NID)
		ENDCASE
		
		Return plReturn
		
	ENDPROC

	PROCEDURE Init
		Lparameters toRec, tnId, tcActiune
		DoDefault()
		This.orec = toRec
		This.nid = tnId
		This.cus_odata_vanzari1.cactiune = tcActiune
		
		
		
	ENDPROC

	PROCEDURE Clb_lucrare.Text_simplu1.DblClick
		thisform.do_alege_lucrare()
		
	ENDPROC

	PROCEDURE Clb_lucrare.Text_simplu1.KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If ((Empty(poRec.id_lucrare) And Empty(porec.nrord)) Or ;
				(Isnull(poRec.id_lucrare) And Isnull(porec.nrord))) ;
				And Inlist(nKeyCode,9,13) And nShiftAltCtrl=0
			thisform.do_alege_lucrare()
		Else
			DoDefault()
		Endif
		
	ENDPROC

	PROCEDURE Clb_partener.Text_simplu1.DblClick
		thisform.do_alege_partener()
		
	ENDPROC

	PROCEDURE Clb_partener.Text_simplu1.KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If ((Empty(poRec.id_part) And Empty(porec.denumire)) Or ;
				(Isnull(poRec.id_part) And Isnull(porec.denumire))) ;
				And Inlist(nKeyCode,9,13) And nShiftAltCtrl=0
			thisform.do_alege_partener()
		Else
			DoDefault()
		Endif
		
	ENDPROC

	PROCEDURE Clb_utilizator.Text_simplu1.DblClick
		thisform.do_alege_utilizator()
	ENDPROC

	PROCEDURE Clb_utilizator.Text_simplu1.KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If ((Empty(poRec.id_util) And Empty(porec.utilizator)) Or ;
				(Isnull(poRec.id_util) And Isnull(porec.utilizator))) ;
				And Inlist(nKeyCode,9,13) And nShiftAltCtrl=0
			thisform.do_alege_utilizator()
		Else
			DoDefault()
		Endif
		
	ENDPROC

	PROCEDURE _image1.Click
		Thisform.do_alege_utilizator()
	ENDPROC

	PROCEDURE _image2.Click
		Thisform.do_alege_lucrare()
	ENDPROC

	PROCEDURE _image3.Click
		Thisform.do_alege_partener()
	ENDPROC

ENDDEFINE

DEFINE CLASS restnir_retetar 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="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_materiiPrime" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboListe" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cbo_idGest_inProd" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_nec.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_nec.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_in_stoc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_in_stoc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cUM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cUM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCante.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCante.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataI" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCodmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCodmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_vand.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_vand.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cPretvtva.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cPretvtva.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_produsa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_produsa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_ramasa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_ramasa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cNr_crt.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cNr_crt.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_de_produs.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_de_produs.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cDen_material.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cDen_material.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cUM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cUM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCant_nec.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCant_nec.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCant_in_stoc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCant_in_stoc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCante.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.cCante.Text1" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: actualizeaza_grid3
		*m: actualizeaza_nec_cum
		*m: actualizeaza_politici_preturi
		*m: assign_analitic
		*m: completeaza_actactan
		*m: completeaza_rultemp
		*p: ccrsretete
		*p: ccrsvanzari
		*p: cfrm_ceredate
		*p: cobj
		*p: nidprodus
		*p: npretvtva
		*p: ntipgest
		*p: nvaloareveche
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton3 = 
		cbuton4 = Ct_grid_order1.But_sterge1;but_reface1
		ccrsretete = creteta
		ccrsvanzari = cweb_vanzari
		cfrm_ceredate = 
		cobj = 
		DoCreate = .T.
		Height = 572
		lactiv1 = .T.
		lactiv3 = .T.
		lactiv4 = .T.
		Name = "restnir_retetar"
		nidprodus = 0
		npretvtva = 0
		ntipgest = 0
		nvaloareveche = 0
		Width = 946
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="ccrsvanzari" display="cCrsVanzari"/>
			<memberdata name="ccrsretete" display="cCrsRetete"/>
			<memberdata name="nvaloareveche" display="nValoareVeche"/>
			<memberdata name="nvaloarenoua" display="nValoareNoua"/>
		</VFPData>
		_shape1.Anchor = 11
		_shape1.Height = 30
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Tag = ""
		_shape1.Top = -1
		_shape1.Width = 949
		_shape1.ZOrderSet = 0
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 820
		_shape2.Name = "_shape2"
		_shape2.Tag = "MOVABLE"
		_shape2.Top = 0
		_shape2.Width = 127
		_shape2.ZOrderSet = 1
		Lb_titlu_alb_b121.Anchor = 3
		Lb_titlu_alb_b121.FontName = "Comic Sans MS"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Height = 20
		Lb_titlu_alb_b121.Left = 4
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 18
		Lb_titlu_alb_b121.Top = 6
		Lb_titlu_alb_b121.Width = 41
		Lb_titlu_alb_b121.ZOrderSet = 2
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 914
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 14
		BUT_TERMIN1.Tag = ""
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 32
		BUT_TERMIN1.ZOrderSet = 5
		Gridsort1.Left = 144
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 1
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 9, ;
		Left = 854, ;
		Name = "But_excel1", ;
		TabIndex = 12, ;
		ToolTipText = "Materii prime cumulate insuficiente in stoc (CTRL+E)", ;
		Top = 1, ;
		Visible = .T., ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Anchor = 9, ;
		Left = 823, ;
		Name = "But_listare1", ;
		TabIndex = 11, ;
		Top = 1, ;
		Visible = .T., ;
		ZOrderSet = 21
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_nou1' AS but_nou WITH ;
		Anchor = 8, ;
		Left = 900, ;
		Name = "But_nou1", ;
		TabIndex = 19, ;
		Top = 82, ;
		ZOrderSet = 22
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 9, ;
		Left = 884, ;
		Name = "But_renunt1", ;
		TabIndex = 13, ;
		Tag = "", ;
		Top = 1, ;
		ZOrderSet = 4
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cbo_idGest_inProd' AS combobox WITH ;
		Anchor = 9, ;
		ColumnCount = 5, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,40,25,15,100", ;
		FontName = "Arial Narrow", ;
		Height = 24, ;
		Left = 783, ;
		Name = "cbo_idGest_inProd", ;
		RowSource = "crsGestiuni.nume_gestiune,cgest,cont,acont,nume_tip", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 10, ;
		Top = 36, ;
		Width = 147, ;
		ZOrderSet = 10
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cboListe' AS combobox WITH ;
		Anchor = 3, ;
		ColumnLines = .F., ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		Format = "", ;
		Height = 24, ;
		Left = 363, ;
		Name = "cboListe", ;
		TabIndex = 5, ;
		Top = 83, ;
		Width = 235, ;
		ZOrderSet = 9
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 3, ;
		Height = 27, ;
		Left = 233, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 4, ;
		Top = 35, ;
		Width = 49, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grid_web' AS _grdrow WITH ;
		Anchor = 7, ;
		ColumnCount = 8, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 456, ;
		HighlightStyle = 2, ;
		Left = 9, ;
		Name = "grid_web", ;
		Panel = 1, ;
		RecordSource = "cWeb_vanzari", ;
		TabIndex = 6, ;
		Top = 109, ;
		Width = 591, ;
		ZOrderSet = 20, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "codmat", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cCodmat", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 44, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "denumire", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cDenumire", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 156, ;
		Column3.ColumnOrder = 5, ;
		Column3.ControlSource = "cant_vand", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(7,gnPCant)), ;
		Column3.Name = "cCant_vand", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 51, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "pretvtva", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(10,gnPPretV)), ;
		Column4.Name = "cPretvtva", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 62, ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "cant_produsa", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "RK", ;
		Column5.InputMask = (get_mask(7,gnPCant)), ;
		Column5.Name = "cCant_produsa", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 66, ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "cant_ramasa_de_scazut", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.InputMask = (get_mask(7,gnPCant)), ;
		Column6.Name = "cCant_ramasa", ;
		Column6.ReadOnly = .T., ;
		Column7.ColumnOrder = 1, ;
		Column7.ControlSource = "nr_crt", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.InputMask = "9999", ;
		Column7.Name = "cNr_crt", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 36, ;
		Column8.ControlSource = "cant_de_produs", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.InputMask = (get_mask(10,gnPCant)), ;
		Column8.Name = "cCant_de_produs"
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web.cCant_de_produs.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. care se produce", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_de_produs.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_produsa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. produsa in perioada", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_produsa.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_ramasa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. ramasa de scazut", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_ramasa.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_vand.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. vanduta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cCodmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod mat.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cNr_crt.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.crt.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cPretvtva.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret de vanz. (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_reteta' AS _grdrow WITH ;
		Anchor = 11, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 202, ;
		HighlightStyle = 2, ;
		Left = 613, ;
		Name = "grid_web_reteta", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "cReteta", ;
		TabIndex = 6, ;
		Top = 109, ;
		Width = 311, ;
		ZOrderSet = 23, ;
		Column1.ControlSource = "den_material", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cDen_material", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 95, ;
		Column2.ColumnOrder = 4, ;
		Column2.ControlSource = "um", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cUM", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 29, ;
		Column3.ColumnOrder = 2, ;
		Column3.ControlSource = "cant_nec", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Format = "RK", ;
		Column3.InputMask = (get_mask(7,gnPCant)), ;
		Column3.Name = "cCant_nec", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 45, ;
		Column4.ColumnOrder = 3, ;
		Column4.ControlSource = "cant_in_stoc", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.InputMask = (get_mask(7,gnPCant)), ;
		Column4.Name = "cCant_in_stoc", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 44, ;
		Column5.ControlSource = "cante", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.InputMask = (get_mask(7,gnPCant)), ;
		Column5.Name = "cCante", ;
		Column5.ReadOnly = .F., ;
		Column5.Width = 59
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web_reteta.cCant_in_stoc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.cCant_in_stoc.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web_reteta.cCant_nec.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate necesara", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.cCant_nec.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web_reteta.cCante.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. care se consuma", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.cCante.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web_reteta.cDen_material.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_reteta.cUM.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 221, ;
		HighlightStyle = 2, ;
		Left = 613, ;
		Name = "grid_web_retetar", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "cWeb_vanzari_retetar", ;
		TabIndex = 8, ;
		Top = 344, ;
		Width = 311, ;
		ZOrderSet = 14, ;
		Column1.BackColor = 255,255,255, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cDenumire", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 95, ;
		Column2.BackColor = 255,255,255, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "cant_nec", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Format = "rk", ;
		Column2.InputMask = (get_mask(10,gnPCant)), ;
		Column2.Name = "cCant_nec", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 45, ;
		Column3.BackColor = 255,255,255, ;
		Column3.ControlSource = "cant_in_stoc", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(10,gnPCant)), ;
		Column3.Name = "cCant_in_stoc", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 44, ;
		Column4.BackColor = 255,255,255, ;
		Column4.ControlSource = "um", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Name = "cUM", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 29, ;
		Column5.ControlSource = "cante", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPCant)), ;
		Column5.Name = "cCante", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 59
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web_retetar.cCant_in_stoc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cCant_nec.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate necesara", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cCante.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate care se scade", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cUM.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 11, ;
		Name = "Label1", ;
		TabIndex = 20, ;
		Top = 39, ;
		Width = 39, ;
		ZOrderSet = 6
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "-", ;
		Height = 17, ;
		Left = 137, ;
		Name = "Label2", ;
		TabIndex = 21, ;
		Top = 40, ;
		Width = 6, ;
		ZOrderSet = 13
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Lista de preturi", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 291, ;
		Name = "Label3", ;
		TabIndex = 22, ;
		Top = 86, ;
		Width = 62, ;
		ZOrderSet = 18
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Materii prime cumulate", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 615, ;
		Name = "Label5", ;
		TabIndex = 16, ;
		Top = 325, ;
		Width = 96, ;
		ZOrderSet = 8
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label8' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Gestiunea in care intra produsele", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 644, ;
		Name = "Label8", ;
		TabIndex = 24, ;
		Top = 39, ;
		Width = 138, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label9' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Vanzari din gestiunea de marfuri aleasa", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 12, ;
		Name = "Label9", ;
		TabIndex = 17, ;
		Top = 86, ;
		Width = 165, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lb_materiiPrime' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Materii prime", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 615, ;
		Name = "lb_materiiPrime", ;
		TabIndex = 15, ;
		Top = 86, ;
		Width = 56, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDataF' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataF", ;
		FontName = "Arial Narrow", ;
		Format = "K", ;
		Height = 23, ;
		Left = 144, ;
		Name = "txtDataF", ;
		TabIndex = 2, ;
		Top = 37, ;
		Width = 81, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtDataI' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataI", ;
		FontName = "Arial Narrow", ;
		Format = "K", ;
		Height = 23, ;
		Left = 53, ;
		Name = "txtDataI", ;
		TabIndex = 1, ;
		Top = 37, ;
		Width = 81, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE actualizeaza_grid1
		Local lcCursorTemp
		save_grid_tag(Thisform.grid_web_reteta)
		save_grid_tag(Thisform.grid_web)
		lcSel = [{call pack_grestaurant.vanzari_stoc(?pnIdGest_InMarf,] + ;
			[?pdDataI,?pdDataF,?gnAn,?gnLuna,?gnIdSucursala)}]
		lnSucces = goExecutor.oExecute(lcSel, Thisform.cCrsVanzari)
		If lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		restore_grid_tag(Thisform.grid_web)
		
		lcCursorTemp = 'crsTempRet'
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
		lcSel = [{call pack_grestaurant.vanzari_retetar(?poAct.id_gestiune,?pnIdGest_InMarf,] + ;
			[?pdDataI,?pdDataF,?gnAn,?gnLuna,?gnIdUtil,?gnIdSucursala)}]
		lnSucces = goExecutor.oExecute(lcSel, lcCursorTemp)
		If lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		copiaza_structura_cursor(lcCursorTemp,Thisform.cCrsRetete)
		If Reccount(lcCursorTemp) > 0
			Select (Thisform.cCrsRetete)
			Append From Dbf(lcCursorTemp)
		Endif
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
		restore_grid_tag(Thisform.grid_web_reteta)
		
		Thisform.actualizeaza_grid2()
		Thisform.grid_web.Refresh()
		Thisform.grid_web.SetFocus()
	ENDPROC

	PROCEDURE actualizeaza_grid2
		Lparameters tlModificare
		Local lcCursor,lnIdArticol,lnCantitate,lcDenumire,lcFiltru,lnIdArticol
		If Reccount(Thisform.cCrsRetete) >0
		*!*		save_grid_tag(Thisform.grid_web_reteta)
			Select (Thisform.cCrsVanzari)
			lnIdArticol = id_articol
			lcFiltru = [id_produs = ] + Alltrim(Str(id_articol))
			lcDenumire = Alltrim(denumire)
			*!*	If cant_ramasa_de_scazut <> cant_de_produs
			If tlModificare
				lnCantitate = cant_de_produs
				Update (Thisform.cCrsRetete) Set cant_nec = cant_mat * lnCantitate, cante = Min(cant_mat * lnCantitate,cant_in_stoc) ;
					Where id_produs = lnIdArticol
		
				Thisform.actualizeaza_nec_cum()
			Endif
		*!*		restore_grid_tag(Thisform.grid_web_reteta)
			Thisform.lb_materiiPrime.Caption = "Materii prime pt.: " + Nvl(lcDenumire,'')
			Select (Thisform.cCrsRetete)
			Set Filter To &lcFiltru
			Go Top
			Thisform.grid_web_reteta.Refresh()
		Endif
		Thisform.actualizeaza_grid3()
		Release lcCursor,lnIdArticol,lnCantitate,lcDenumire,lcFiltru,lnIdArticol
		
	ENDPROC

	PROCEDURE actualizeaza_grid3
		Local lcCursor,lcCursorReteta
		lcCursor = Thisform.grid_web_retetar.RecordSource
		save_grid_tag(Thisform.grid_web_retetar)
		Select id_material, den_material as denumire, ;
			SUM(cant_nec) As cant_nec, ;
			CAST(Sum(cante) As N(10,gnPCant)) As cante, ;
			cant_in_stoc, um, ;
			MIN(adaugat) as adaugat ;
			FROM (Thisform.cCrsRetete) ;
			WITH (Buffering = .T.) ;
			Group By id_material, den_material, cant_in_stoc, um, adaugat ;
			ORDER By den_material ;
			INTO Cursor (lcCursor)
		restore_grid_tag(Thisform.grid_web_retetar)
		Thisform.grid_web_retetar.Refresh()
	ENDPROC

	PROCEDURE actualizeaza_nec_cum
		LOCAL lcCursorTemp,lnIdArticol,lnCantitate 
		lcCursorTemp = [crsTempCumRet]
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
		Select id_material,Sum(cante) As cantnec From (Thisform.cCrsRetete) Group By id_material Into Cursor (lcCursorTemp)
		Scan
			lnCantitate = cantnec
			lnIdArticol = id_material
			Update (Thisform.cCrsRetete) Set cant_nec_cum = lnCantitate Where id_material = lnIdArticol
			Select (lcCursorTemp)
		Endscan
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
	ENDPROC

	PROCEDURE actualizeaza_politici_preturi
		Lparameters tnTip
		If tnTip = 0
			Thisform.cboListe.ColumnCount =	0
			Thisform.cboListe.ColumnWidths = []
			Thisform.cboListe.RowSource	= []
			Thisform.cboListe.RowSourceType	=	0
			Thisform.cboListe.Style	= 0
			Thisform.cboListe.Enabled = .F.
			If Used('cListePreturi')
				Use In cListePreturi
			Endif
		Else
			If Used('cListePreturi')
				Use In cListePreturi
			Endif
			Create Cursor cListePreturi(nume_lista_preturi C(200),id_pol N(10))
			Insert Into cListePreturi(nume_lista_preturi,id_pol) Values('<TOATE>',-9999)
			Insert Into cListePreturi(nume_lista_preturi,id_pol) Select Distinct Substr(nume_lista_preturi,1,200),id_pol From cweb_vanzari Order By 1
		
			If Reccount('cListePreturi') > 2
				Select cListePreturi
				Go Top
				Thisform.cboListe.ColumnCount	=	2
				Thisform.cboListe.ColumnWidths = [200,0]
				Thisform.cboListe.RowSource	= [cListePreturi.nume_lista_preturi,id_pol]
				Thisform.cboListe.RowSourceType	=	2
				Thisform.cboListe.Style	= 2
				Thisform.cboListe.Enabled = .T.
				Thisform.cboListe.Value = cListePreturi.nume_lista_preturi
			Endif
		Endif
	ENDPROC

	PROCEDURE assign_analitic
		PARAMETERS tcCont,pcAct,pcRul
		
		PRIVATE pcCont,pcAct,pcRul,pParamP,pParamS
		STORE 0 TO pParamP,pParamS
		lcAnalitic = ''
		lcAlias = ALIAS()
		
		pcCont = ALLTRIM(tcCont)
		
		lcSel = [SELECT * from ] + gcs + [.config_analitice WHERE cont = ?pcCont]
		lcCursor = 'crs_cfg_ana'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		IF lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_cfg_ana')=0
				USE IN crs_cfg_ana
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			SELECT crs_cfg_ana
			SCATTER NAME ocfg
			lcCampPrefix = NVL(ALLTRIM(ocfg.camp_leg_prefix),'')
			lcCampSufix = NVL(ALLTRIM(ocfg.camp_leg_sufix),'')
			
			IF !EMPTY(lcCampPrefix)
				IF TYPE('&pcRul..'+lcCampPrefix) # 'U'
					pParamP = &pcRul..&lcCampPrefix
				ELSE 
					IF TYPE('&pcAct..'+lcCampPrefix) # 'U'
						pParamP = &pcAct..&lcCampPrefix
					ENDIF 
				ENDIF 
			ENDIF 
			
			IF !EMPTY(lcCampSufix)
				IF TYPE('&pcRul..'+lcCampSufix) # 'U'
					pParamS = &pcRul..&lcCampSufix 
				ELSE 
					IF TYPE('&pcAct..'+lcCampSufix) # 'U'
						pParamS = &pcAct..&lcCampSufix 
					ENDIF 
				ENDIF 
			ENDIF 
		
			lcSel = [{call fconturi_analitice(?gcs,?pcCont,0,?pParamP,?pParamS)}]
			lcCursor = 'crs_analitice'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		&& iau Primul Simbol Analitic din Tabel - ordonat pt ca e selectat cu Distinct
		IF lnSucces > 0
			SELECT crs_analitice
			GO top
			lcAnalitic = ALLTRIM(acont)
		ENDIF 
		
		&& verificare analiticului cu Planul de Conturi
		IF lnSucces > 0
			lcSel = [SELECT cont,acont from ] + gcs + [.vplcont_analitic WHERE cont = ?pcCont and acont = ?lcAnalitic and an = ?gnAn ]
			lcCursor = 'crs_verific'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_verific')=0
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF USED('crs_cfg_ana')
			USE IN crs_cfg_ana
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		IF USED('crs_analitice')
			USE IN crs_analitice
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		
		IF lnSucces < 0
			lcAnalitic = ''
		ENDIF 
		
		SELECT (lcAlias)
		RETURN lcAnalitic
		
	ENDPROC

	PROCEDURE completeaza_actactan
		Local lcSelRul, lcContTr, lcAcontTr, lcRul, lcSql, lcCursor, lnSucces, lcCant
		Store '' To lcContTr, lcAcontTr
		
		llSucces = This.completeaza_rultemp()
		If !llSucces
			Return .F.
		Endif
		
		Local lnRecno
		lnRecno = 0
		
		*** completez tabela ACTACTAN
		If Type('oitem') = 'O'
			If Pemstatus(oitem,'adunadate',5)
				oitem.adunadate()
			Endif
		ENDIF
		
		&& NOTE
		Select * From XNOTE Where id_set = oset.id_set Into Cursor crsNota
		
		lcField = ''
		Select xact
		Go Top
		
		For i = 1 To Fcount()
			If Upper(Alltrim(Evaluate(Field(i)))) = 'SUMA'
				lcField = Field(i)
				Exit
			Endif
		Endfor
		
		If Empty(lcField)
			Return .T.
		Endif
		
		Private pnBazaBon,pnBazaNir,pnTvaVanzIn,pnAdaosVanzIn,pnBazaVanz
		Store 0 To pnBazaBon,pnBazaNir,pnTvaVanzIn,pnAdaosVanzIn,pnBazaVanz
		
		Select cweb_vanzari
		Calculate Sum(Round(pret*cant_de_produs,gnPc)),Sum(Round(tvav*cant_de_produs,gnPc)),;
			Sum(Round(pretftva*cant_de_produs,gnPc)) ;
			TO pnBazaNir,pnTvaVanzIn,pnBazaVanz
		
		Select rul_temp
		Calculate Sum(Round(Pret*cante, gnPC)) To pnBazaBon For Cont = '301'
		
		pnAdaosVanzIn = pnBazaVanz - pnBazaNir
		
		Select actactan
		Scatter Name loActactan
		Replace suma With pnBazaBon FOR scd = '601' AND scc = '301'
		Replace suma WITH pnBazaNir,id_gestin With pnIdGest_InProd For scd = '345' And scc = '711'
		Replace suma WITH pnBazaNir,id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InProd For scd = '371' And scc = '345'
		If Thisform.ntipgest = 6
			Replace suma With pnAdaosVanzIn, id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InMarf For scd = '371' And scc = '378'
			Replace suma With pnTvaVanzIn,id_gestin With pnIdGest_InMarf,id_gestout With pnIdGest_InMarf For scd = '371' And scc = '4428'
		Endif
		
		Select Distinct acont From rul_temp Where Cont = '301' Into Cursor cAcont301
		Select cAcont301
		Scan
			lnValAchizitie = 0
			lcAcont = NVL(acont,'')
			Select rul_temp
			Calculate Sum(Round(Pret*cante, gnPC)) To lnValAchizitie For Cont = '301' And NVL(acont,'') = lcAcont
			Select actactan
			Locate For scc = '301' And Empty(NVL(ascc,''))
			If Found()
				Replace suma With lnValAchizitie, ascc With lcAcont
			Else
				Select actactan
				Locate For scc = '301'
				Scatter Name lo301
				Append Blank
				Gather Name lo301
				Replace suma With lnValAchizitie, ascc With lcAcont
			Endif
			Select cAcont301
		Endscan
		
		Select rul_temp
		Replace All dataact With loActactan.dataact, ;
			nnir With loActactan.nnir, ;
			id_sectie With loActactan.id_sectie, ;
			id_responsabil With loActactan.id_responsabil, ;
			id_lucrare With loActactan.id_lucrare
		If Used('crsNota')
			Use In crsNota
		Endif
		
		&& ordonez notele contabile in ACTACTAN
		Select actactan
		Sum suma To lnSume
		
		If lnSume <> 0
			lcCondDele = [!(suma = 0 and !(((left(scd,1) = '3' and left(scc,2) = '40') OR (left(scd,2) = '41' and left(scc,1) = '7')) AND proc_tva # 1))]
		Else
			lcCondDele = [suma = 0 AND nr_nota = 1 ]
		Endif
		
		Select * From actactan Into Cursor crsActActan Where &lcCondDele Or Inlist(id_set, 89, 210, 211, 212) Order By nr_nota NOFILTER Readwrite
		
		Select actactan
		Delete From actactan
		Append From Dbf('crsactactan')
		If Used('crsactactan')
			Use In crsActActan
		Endif
		
		&& completare analitice
		Select actactan
		Scan For Empty(Nvl(ascd,''))
			Scatter Name loActactan
			If Type('loActactan.cont') = 'U'
				x = AddProperty(loActactan,'cont',loActactan.scd)
			Endif
			If oset.model = 2 And Type('loActactan.id_gestiune') = 'U'              && NIR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestin)
			Endif
			If Inlist(oset.model, 3, 4) And Type('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestout)
			Endif
			loActactan.ascd = This.assign_analitic(loActactan.scd,This.cobj,'loActactan')
			Replace ascd With loActactan.ascd
			Select actactan
		Endscan
		
		Select actactan
		Scan For Empty(Nvl(ascc,''))
			Scatter Name loActactan
			If Type('loActactan.cont') = 'U'
				x = AddProperty(loActactan,'cont',loActactan.scc)
			Endif
			If oset.model = 2 And Type('loActactan.id_gestiune') = 'U'              && NIR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestin)
			Endif
			If Inlist(oset.model, 3, 4) And Type('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestout)
			Endif
			loActactan.ascc = This.assign_analitic(loActactan.scc,This.cobj,'loActactan')
			Replace ascc With loActactan.ascc
			Select actactan
		Endscan
		
		Select actactan
		Locate For scd = '371' And scc = '345'
		If Found()
			lcAscd = ascd
			Select rul_temp
			Replace All acont With lcAscd For Cont = '371' And cante <> 0 And cant = 0
		Endif
		
		If Thisform.ntipgest = 6
			Select actactan
			Locate For scd = '371' And scc = '378'
			If Found()
				lcAscd = ascd
				Select rul_temp
				Replace All acont With lcAscd For Cont = '371' And cante = 0 And cant <> 0
				Select actactan
				Replace id_gestout With 0 For scd = '371' And scc = '378'
			Endif
		Endif
		
		*!*	Select actactan
		*!*	Replace id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InProd For scd = '371' And scc = '345'
		
		If Type('loActactan') = 'O'
			Release loActactan
		Endif
		
		Select actactan
		Go Top
		
		Return .T.
		
	ENDPROC

	PROCEDURE completeaza_rultemp
		&& completez RUL_TEMP
		lcProduse = This.grid_web.RecordSource
		lcMateriale = This.grid_web_retetar.RecordSource
		
		If Used('rul_temp')
			Use In rul_temp
		Endif
		
		* lcRul = ALLTRIM(THIS.osel_dr.cfrom)
		lcSql = [select v.*, v.id_gestiune as id_gestin, v.nume_gestiune as gestin, v.id_gestiune as id_gestout,] + ;
			[v.nume_gestiune as gestout, 0 as nuInConturiX from ] + gcS + [.vrul v where 1=2]
		lcCursor = [rul_temp]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		Endif
		
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		
		lcSql = [select id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont, SUM(cants + cant - cante) as stoc ] + ;
			[from stoc where an = ] + Transform(gnAn) + [ and luna = ] + Transform(gnLuna) + ;
			[ and id_gestiune in (] + Transform(poAct.id_gestiune)+ [) and NVL(id_rul_aux,0) = 0 ] + gcCondSucursala + ;
			[ group by id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont order by pret]
		lcCursor = [crsStocActual1]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		Endif
		
		If Used("crsStocActual")
			Use In crsStocActual
		Endif
		
		Select * From crsStocActual1 ;
			WITH (Buffering = .T.) ;
			INTO Cursor crsStocActual ;
			READWRITE
		
		Select * From crsStocActual1 ;
			WITH (Buffering = .T.) ;
			INTO Cursor crsStocActual_2 ;
			READWRITE
		
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		
		If Used("crsMateriale")
			Use In crsMateriale
		Endif
		*!*	SELECT id_material AS id_articol, IIF(cant_nec < cant_in_stoc, cant_nec, cant_in_stoc) AS cante ;
		*!*		FROM (lcMateriale) ;
		*!*		WITH (buffering = .t.) ;
		*!*		INTO CURSOR crsMateriale ;
		*!*		READWRITE
		
		Select id_material As id_articol, cante ;
			FROM (lcMateriale) ;
			WITH (Buffering = .T.) ;
			where cante > 0 ;
			INTO Cursor crsMateriale ;
			READWRITE
		
		Select crsMateriale
		Scan
			lnCantRamas = cante
			lnIdArticol = id_articol
			lnCantInit = cante
			*!*		lcMaterial = ALLTRIM(denumire)
			Select crsStocActual
			Locate For id_articol = lnIdArticol And stoc > 0
			Do While Found() And lnCantRamas > 0
				lcCont = Cont
				lcAcont = Nvl(acont,'')
		
				lnCante = Min(lnCantRamas, stoc)
				lnCantRamas = lnCantRamas - lnCante
				lnPret = Pret
				lnIdGestiune = id_gestiune
		
				*!*		INSERT INTO test (material, id_mat, cant_nec, cante, cantramas, stoc, pret) VALUES (lcMaterial, lnIdArticol, lnCantInit, lnCante, lnCantRamas, crsStocActual.stoc, lnPret)
				Replace stoc With stoc - lnCante
		
				If Left(lcCont,3) <> '371'
					Select rul_temp
					Scatter Name loRul Blank
					With loRul
						.id_articol = lnIdArticol
						*.id_gestout = lnIdGestiune
						.id_gestiune = lnIdGestiune
						.cante = lnCante
						.Pret = Round(lnPret, gnPpret)
						.Cont = lcCont
						.acont = lcAcont
					Endwith
					Select rul_temp
					Append Blank
					Gather Name loRul
				Endif
		
				Select crsStocActual
				Locate For id_articol = lnIdArticol And stoc > 0 And lnCantRamas > 0
			Enddo
			Select crsMateriale
		Endscan
		
		If Used("crsMateriale")
			Use In crsMateriale
		Endif
		
		**********************************************************************
		* 345 = 711 - intrare produs la pret de achizitie materiale componente
		* nuProdus ex.: chifle, banane - pe care le cumpara direct ca marfa, si nu devin produse
		**********************************************************************
		Select id_articol, cant_de_produs As cant, Pret, tvav, pretftva, proc_tvav, ;
			0 As nuProdus ;
			FROM (lcProduse) ;
			WITH (Buffering = .T.) ;
			WHERE cant_de_produs > 0 ;
			INTO Cursor crsProduseIesiri ;
			READWRITE
		
		Select crsProduseIesiri
		Scan
			Scatter Name loProdus
			lnIdArticol = id_articol
		*!*		lnPretvtva = pretvtva
			lnCant = cant
			Select * From (Thisform.cCrsRetete) ;
				WHERE id_produs = lnIdArticol ;		&&	And pretvtva = lnPretvtva
			Into Cursor cCalcReteta
		
			lnPretCalc = 0
			lnComponente = 0
			lnComponenteGasite = 0
			Select cCalcReteta
			Scan
				lnComponente = lnComponente + 1
				lnCantRamas = cante
				lnId_material = id_material
				lnCantInit = cante
				Select crsStocActual_2
				Locate For id_articol = lnId_material And stoc > 0
				Do While Found() And lnCantRamas > 0
					If Left(Cont,3) = '371'
						lnComponenteGasite = lnComponenteGasite + 1
					Endif
					lnCante = Min(lnCantRamas, stoc)
					lnCantRamas = lnCantRamas - lnCante
					lnPret = Pret
					Replace stoc With stoc - lnCante
		
					lnPretCalc = Round(lnPretCalc + Round(lnCante * lnPret, gnPpret), gnPpret)
					*!*				Select crsStocActual_2
					*!*				Locate For id_articol = lnId_material And stoc > 0 And lnCantRamas > 0
					Continue
				Enddo
		
				Select cCalcReteta
			Endscan
		
			If Used("cCalcReteta")
				Use In cCalcReteta
			Endif
		
			If lnComponenteGasite < lnComponente
				&& daca toate componentele sunt in stoc pe contul 371, nu mai scriu in rul_temp
				Select rul_temp
				Append Blank
				Gather Name loProdus FIELDS LIKE id_articol,cant,pret
		*!*			Replace Pret With Round(lnPretCalc/lnCant, gnPpret), Cont With '345', id_gestiune With pnIdGest_InProd
				Replace Cont With '345', id_gestiune With pnIdGest_InProd
			Else
				Select crsProduseIesiri
				Replace nuProdus With 1
			Endif
		
		*!*		Select crsProduseIesiri
		*!*		Replace Pret With Round(lnPretCalc/lnCant, gnPpret)
		
			Select crsProduseIesiri
		Endscan
		
		**********************************************************************
		* 371 = 345 - iesire produs
		**********************************************************************
		Select crsProduseIesiri
		Scan For nuProdus = 0
			Scatter Name loProdus
		
			Select rul_temp
			Append Blank
			Gather Name loProdus FIELDS LIKE id_articol, pret
			Replace cante With Round(loProdus.cant,gnPCant), ;
				CONT With '345', ;
				id_gestiune With pnIdGest_InProd
		
			Select rul_temp
			Append Blank
			Gather Name loProdus Fields Like id_articol, cant, Pret
			Replace Cont With '371', ;
				id_gestiune With pnIdGest_InMarf
			If Thisform.ntipgest = 6
				Replace pretv With loProdus.pretftva, ;
					proc_tvav WITH loProdus.proc_tvav,;
					adaos With loProdus.pretftva - loProdus.pret, ;
					adaos_tva With Round(Round(loProdus.pretftva-loProdus.Pret,max(gnPpret,gnPPretV))*Iif(proc_tvav <> 0, proc_tvav-1,0),max(gnPpret,gnPPretV)), ;
					tvav With tvav
			Endif
			Select crsStocActual
		Endscan
		
		If Used("crsStocActual")
			Use In crsStocActual
		Endif
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		If Used("crsProduseIesiri")
			Use In crsProduseIesiri
		Endif
	ENDPROC

	PROCEDURE Destroy
		If Used('cListePreturi')
			Use In cListePreturi
		Endif
		
		If Used(Thisform.cCrsVanzari)
			Use In (Thisform.cCrsVanzari)
		Endif
		
		If Used("cWeb_vanzari_retetar")
			Use In cWeb_vanzari_retetar
		Endif
		
		If Used(Thisform.cCrsRetete)
			Use In (Thisform.cCrsRetete)
		Endif
		
	ENDPROC

	PROCEDURE do_adauga
		Local lnId_Produs,lnCantitate,loas,lnAdaugat 
		loas = Createobject("frm_alege_din_stoc")
		loas.lb_titlu_alb_b121.Caption = "STOC"
		Select xsets
		Locate For id_set = 106 && tnIdSet
		Scatter Name oSet
		*!*	modificare JC/JV 2007
		If gnNeplatitoare_tva = 1
			oSet.id_jtax = oSet.id_jtaxn
			oSet.id_jnetax = oSet.id_jtaxn
		Endif
		*!*	modificare JC/JV 2007	^
		lFactura = oSet.factura
		lAdaos = oSet.adaos
		lDiscount = oSet.discount
		lcTipFrm = Upper(oSet.explicatia)
		llGestout = .F.
		
		Select selectii
		Locate For id_sel = oSet.id_selSt
		If Found()
			Scatter Name ost Memo
		Else
			amessagebox('NECONFIGURAT!',48,'Atentie!')
			Return 2 && renunt
		Endif
		
		lcSelSt = Alltrim(ost.cselect) + [ from ] + gcs + [.] + Alltrim(ost.cfrom) + [ where ] + Alltrim(ost.filtru)
		lcSchemaSt = Alltrim(ost.cschema)
		
		With loas.ct_grid_search1
			.cselect = lcSelSt
			.cschema = lcSchemaSt
			.cTitlu_coloane = Alltrim(ost.titlu_col)
			.cNume_coloane = Alltrim(ost.nume_col)
			.cMask = Alltrim(ost.mask_col)
			.cFiltruOriginal = Strtran(Alltrim(Evaluate(ost.filtruorig)),[<>],[>]) +  [ and id_gestiune = ?poAct.id_gestiune ]
			.cFiltru = Alltrim(ost.filtru)
			.cOrder = Alltrim(ost.ordine)
			.cTitlu = Alltrim(ost.titlu_grid)
			.cb_tx_gestout.Visible = llGestout
			.but_nou1.Visible = llAdMod
			*	.but_modifica1.VISIBLE = llAdMod
		Endwith
		loas.Show(1)
		
		If buton = 2
			Return
		Endif
		
		Select cursor_curent1
		If Reccount() > 0
			Scatter Name loArticol
			Select (Thisform.cCrsRetete)
			lnId_Produs = id_produs
			Locate For id_material = loArticol.id_articol
			If !Found()
				lnAdaugat = 1
				Append Blank
				Replace id_produs With lnId_Produs, ;
					id_material With loArticol.id_articol, ;
					den_material With loArticol.denumire, ;
					cant_nec With 0, ;
					cant_in_stoc With loArticol.cantitate, ;
					um With loArticol.um, ;
					adaugat With lnAdaugat
				Select (Thisform.grid_web_retetar.RecordSource)
				Locate For id_material = loArticol.id_articol
				If Found()
					lnCantitate = cant_nec
				Else
					lnCantitate = 0
				Endif
				Select (Thisform.cCrsRetete)
				Replace cant_nec_cum With lnCantitate
			Else
				lnAdaugat = 0
			Endif
			Thisform.actualizeaza_grid3()
			Select (Thisform.grid_web_retetar.RecordSource)
			Locate For id_material = loArticol.id_articol And adaugat = lnAdaugat
			Thisform.grid_web_retetar.Refresh()
			Thisform.grid_web_reteta.Refresh()
			Thisform.grid_web_reteta.cCante.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta
		Do Case
			Case Empty(gcGestPermis)
				AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
				Return
			Case Empty(pdDataI)
				AMESSAGEBOX("Completati data initiala !",0+48,"Atentie")
				Thisform.txtDataI.SetFocus()
				Return
			Case Empty(pdDataF)
				AMESSAGEBOX("Completati data finala !",0+48,"Atentie")
				Thisform.txtDataF.SetFocus()
				Return
				*!*		CASE pdDataI < DATE(gnAn,gnLuna,1)
				*!*			amessagebox("Data initiala trebuie sa fie din luna curenta!",0+48,"Atentie")
				*!*			Thisform.txtDataI.SetFocus()
				*!*			RETURN
				*!*		CASE pdDataF >= GOMONTH(DATE(gnAn,gnLuna,1),1)
				*!*			amessagebox("Data finala trebuie sa fie din luna curenta!",0+48,"Atentie")
				*!*			Thisform.txtDataF.SetFocus()
				*!*			RETURN
			Otherwise
				pcPerioada = Dtoc(pdDataI) + " - " + Dtoc(pdDataF)
		Endcase
		
		Thisform.actualizeaza_politici_preturi(0)
		Thisform.actualizeaza_grid1()
		IF RECCOUNT(Thisform.cCrsVanzari) > 0
			Update (Thisform.cCrsVanzari) Set nuInRetetar = 1 Where id_articol Not In (Select Distinct id_produs From (Thisform.cCrsRetete))
			Select (Thisform.cCrsVanzari)
			Locate For nuInRetetar = 1
			If Found()
				AMESSAGEBOX("Exista produse care nu au definita fisa tehnologica!",0+48,"Definiti fisa tehnologica!")
			ELSE
				GO top
			Endif
		
			Thisform.actualizeaza_politici_preturi(1)
		*!*		Thisform.grid_web.AfterRowColChange()
		ELSE
			amessagebox("Nu exista rezultate pentru perioada selectata!",48,"Atentie")
			Thisform.txtDataI.SetFocus()
		ENDIF
	ENDPROC

	PROCEDURE do_excel
		DO export_excel_grid WITH this.grid_web_retetar, 'denumire', "cant_nec > cant_in_stoc" IN proceduri_excel.prg
	ENDPROC

	PROCEDURE do_termin
		IF this.inainte_de_do_termin()
			gnButon = 1
			pnButon = 1
			Buton = 1
			pnIesire = 1
			*this.Hide 
			SELECT actactan
			llVerificare = verificare_note_contabile('actactan', .T.,.T., .F.)
			If !llVerificare
				This.AlwaysOnTop = .F.
				Do Form verificare With .T.,.T.,3  && cu buton de precedent
				This.AlwaysOnTop = .T.
			Endif
			
			DO CASE 
				CASE gnButon = 3
					*onirbon.visible = .t.
					* DO nrord WITH lcSelRul
				OTHERWISE 
					this.Release 
			ENDCASE 
		ENDIF 
	ENDPROC

	PROCEDURE inainte_de_do_listare
		Thisform.AlwaysOnTop = .F.
		
		Select * From (Thisform.grid_web_retetar.RecordSource) Where cant_nec > cant_in_stoc Into Cursor cList
		goExport.export2frx([cList],[rap_descarcare_retetar])
		If Used("cList")
			Use In cList
		Endif
		
		Thisform.AlwaysOnTop = .T.
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local llReturn
		llReturn = .F.
		Do Case
			Case Empty(gcGestPermis)
				AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			Case !Used("cWeb_Vanzari")
				AMESSAGEBOX("Nu exista inregistrari!",0+48,"Atentie")
			Case Empty(pnIdGest_InProd)
				AMESSAGEBOX("Nu ati completat gestiunea in care intra produsele!",0+48,"Atentie")
				Thisform.cbo_idGest_inProd.SetFocus()
			Otherwise
				Select (Thisform.grid_web.RecordSource)
				Locate For cant_de_produs > 0
				If !Found()
					AMESSAGEBOX("Nu ati completat cantitatile!",48,"Atentie")
					Thisform.grid_web.SetFocus()
				Else
					Locate For nuInRetetar = 1 And cant_de_produs > 0
					If Found()
						AMESSAGEBOX("Exista produse care nu au definita fisa tehnologica!",0+48,"Atentie")
						Thisform.grid_web.SetFocus()
					Else
						Select (Thisform.grid_web_retetar.RecordSource)
						Locate For cante > cant_in_stoc
						If Found()
							AMESSAGEBOX("Exista materii prime pentru care cantitatea care se scade depaseste cantitatea din stoc!",0+48,"Atentie")
							Thisform.grid_web_reteta.SetFocus()
						Else
							Locate For cante > 0
							If !Found()
								AMESSAGEBOX("Nu ati completat cantitatile pentru materiale!",48,"Atentie")
								Thisform.grid_web_retetar.SetFocus()
							Else
								llReturn = Thisform.completeaza_actactan()
							Endif
						Endif
					Endif
				Endif
		Endcase
		Return llReturn
		
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Thisform.cCrsVanzari = Alltrim(Thisform.grid_web.RecordSource)
		Thisform.cCrsRetete = Alltrim(Thisform.grid_web_reteta.RecordSource)
		
	ENDPROC

	PROCEDURE Show
		Lparameters nStyle
		Local loCauta
		pnIdGest_InMarf = 0
		Do While pnIdGest_InMarf = 0
			loCauta = caut_gestiune(0,gnIdUtil,.F.,[ALEGETI GESTIUNEA IN CARE INTRA MARFURILE])
			If gnButon = 1
				pnIdGest_InMarf = loCauta.id_gestiune
				Thisform.ntipgest = loCauta.nr_pag
				DoDefault(nStyle)
			Else
				Nodefault
				Return .F.
			Endif
		Enddo
		Select crsGestiuni
		Locate For id_gestiune = pnIdGest_InMarf
		If Found()
			pnIdGest_InProd = pnIdGest_InMarf
			Thisform.cbo_idGest_inProd.Value = Alltrim(nume_gestiune)
		Else
			Go Top
		Endif
	ENDPROC

	PROCEDURE cboListe.Valid
		Select (Thisform.grid_web.RecordSource)
		If cListePreturi.id_pol <> -9999
			Set Filter To id_pol = cListePreturi.id_pol
		Else
			Set Filter To
		Endif
		Thisform.grid_web.Refresh()
		
	ENDPROC

	PROCEDURE cbo_idGest_inProd.Valid
		pnIdGest_InProd = crsGestiuni.id_gestiune
		
	ENDPROC

	PROCEDURE grid_web.AfterRowColChange
		Lparameters nColIndex
		If Inlist(This.RowColChange,1,3)
			Thisform.actualizeaza_grid2()
		Endif
		
	ENDPROC

	PROCEDURE grid_web.cCant_de_produs.Text1.GotFocus
		Thisform.nValoareVeche = This.Value
	ENDPROC

	PROCEDURE grid_web.cCant_de_produs.Text1.Valid
		Do Case
			Case This.Value < 0
				Wait Window 'Cantitatea trebuie sa fie nenegativa!' Nowait
				Select (Thisform.grid_web.RecordSource)
				Replace cant_de_produs With Thisform.nValoareVeche
			Case Thisform.nValoareVeche <> This.Value
				Thisform.actualizeaza_grid2(.T.)
			Otherwise
				*!*	nimic
		Endcase
	ENDPROC

	PROCEDURE grid_web.cDenumire.Text1.DblClick
		LOCAL lcTabelProduse, lnId_Produs, lcDenumire_pr  
		STORE '' TO lcTabelProduse, lcDenumire_pr  
		STORE 0 TO lnId_Produs
		
		lcTabelProduse = thisform.grid_web.RecordSource
		SELECT (lcTabelProduse)
		
		lnId_Produs = id_articol
		lcDenumire_pr = ALLTRIM(denumire)
		 
		Private poReteta
		Store '' To poReteta
		
		Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
		*!*	lcSchema1 = [id_ctr N(5), id_part N(10), nume C(30), nr_ctr N(10), data_ctr D(8), obiect C(200), tip N(1), durata N(3), valftva N(20,4), proc_tva N(5,2), avans N(20,4), proc_avans N(5,2),]+;
		*!*		[val_finant N(20,4), proc_finant N(5,2), dobanda N(20,4), proc_dobanda N(5,2), val_rezid N(20,4), proc_rezid N(5,2), ]+;
		*!*		[rata N(20,4), comision N(20,4), proc_comision N(5,2), proc_asigurare N(5,2), val_asigurare N(20,4), val_ctr N(20,4), id_valuta N(5), nume_val C(4), curs N(10,4), zi_plata N(2), incetat N(1), sters N(1) ]
		
		lcSelect1 = [select id_material, denumire_mat, codmat_mat, um_mat, cont_mat, cant_mat from ] + gcS + [.vgest_retetar ]
		lcOrder1 = []
		lcgroup = []
		lcFiltru1 = [id_produs=] + ALLTRIM(STR(lnId_Produs))
		lcFiltruOriginal = []
		llModParam = .T.
		llAfiseaza = .F.
		
		gencursor('poReteta','crsReteta', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		poReteta.ca_baza1.afisare()
		
		SELECT crsReteta
		lofr = CREATEOBJECT("frm_reteta")
		lofr.lb_titlu_alb_b121.caption = "Reteta pentru: " + lcDenumire_pr 
		lofr.show(1)
		
		IF USED("crsReteta")
			USE IN crsReteta
		ENDIF 
		
		RELEASE poReteta
	ENDPROC

	PROCEDURE grid_web.Init
		This.SetAll("DynamicBackColor","IIF(nuInRetetar = 1, RGB(255,0,0), RGB(255,255,255))", "Column")
		This.cCant_de_produs.DynamicBackColor = "IIF(nuInRetetar = 1, RGB(255,0,0),RGB(187,235,255))"
	ENDPROC

	PROCEDURE grid_web_reteta.AfterRowColChange
		Lparameters nColIndex
		If Inlist(This.RowColChange,1,3)
			Local lnId_material,lnAdaugat
			Store 0 To lnId_material,lnAdaugat
		
			Select (This.RecordSource)
			lnId_material = id_material
			lnAdaugat = adaugat
		
			Select (Thisform.grid_web_retetar.RecordSource)
			Locate For id_material = lnId_material AND adaugat = lnAdaugat
			Thisform.grid_web_retetar.Refresh()
		Endif
	ENDPROC

	PROCEDURE grid_web_reteta.cCante.Text1.GotFocus
		Thisform.nValoareVeche = This.Value
	ENDPROC

	PROCEDURE grid_web_reteta.cCante.Text1.Valid
		Do Case
			Case This.Value < 0
				Wait Window 'Cantitatea trebuie sa fie nenegativa!' Nowait
				Select (Thisform.grid_web_reteta.RecordSource)
				Replace cant_de_produs With Thisform.nValoareVeche
			Case This.Value <> Thisform.nValoareVeche
				Local lnCant_Max,lnIdMaterial,lnAdaugat
				Store 0 To lnCant_Max
		
				Select (Thisform.grid_web_reteta.RecordSource)
				lnCant_Max = Iif(adaugat = 1,cant_in_stoc-cant_nec_cum,Min(cant_nec,cant_in_stoc-cant_nec_cum))
				lnIdMaterial = id_material
				lnAdaugat = adaugat
		
				If This.Value > lnCant_Max
					Wait Window 'Nu puteti scoate o cantitate mai mare decat cea aflata in stoc/necesara !' Nowait
					Replace cante With lnCant_Max
				Endif
		
				Thisform.grid_web_reteta.Refresh
				Thisform.actualizeaza_grid3()
				Select (Thisform.grid_web_retetar.RecordSource)
				Locate For id_material = lnIdMaterial And adaugat = lnAdaugat
				Thisform.grid_web_retetar.Refresh()
				Thisform.grid_web_reteta.Refresh()
			Otherwise
				*!*	nimic
		Endcase
	ENDPROC

	PROCEDURE grid_web_reteta.cDen_material.Text1.DblClick
		LOCAL lcTabelProduse, lnId_Produs, lcDenumire_pr  
		STORE '' TO lcTabelProduse, lcDenumire_pr  
		STORE 0 TO lnId_Produs
		
		lcTabelProduse = thisform.grid_web.RecordSource
		SELECT (lcTabelProduse)
		
		lnId_Produs = id_articol
		lcDenumire_pr = ALLTRIM(denumire)
		 
		Private poReteta
		Store '' To poReteta
		
		Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
		*!*	lcSchema1 = [id_ctr N(5), id_part N(10), nume C(30), nr_ctr N(10), data_ctr D(8), obiect C(200), tip N(1), durata N(3), valftva N(20,4), proc_tva N(5,2), avans N(20,4), proc_avans N(5,2),]+;
		*!*		[val_finant N(20,4), proc_finant N(5,2), dobanda N(20,4), proc_dobanda N(5,2), val_rezid N(20,4), proc_rezid N(5,2), ]+;
		*!*		[rata N(20,4), comision N(20,4), proc_comision N(5,2), proc_asigurare N(5,2), val_asigurare N(20,4), val_ctr N(20,4), id_valuta N(5), nume_val C(4), curs N(10,4), zi_plata N(2), incetat N(1), sters N(1) ]
		
		lcSelect1 = [select id_material, denumire_mat, codmat_mat, um_mat, cont_mat, cant_mat from ] + gcS + [.vgest_retetar ]
		lcOrder1 = []
		lcgroup = []
		lcFiltru1 = [id_produs=] + ALLTRIM(STR(lnId_Produs))
		lcFiltruOriginal = []
		llModParam = .T.
		llAfiseaza = .F.
		
		gencursor('poReteta','crsReteta', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		poReteta.ca_baza1.afisare()
		
		SELECT crsReteta
		lofr = CREATEOBJECT("frm_reteta")
		lofr.lb_titlu_alb_b121.caption = "Reteta pentru: " + lcDenumire_pr 
		lofr.show(1)
		
		IF USED("crsReteta")
			USE IN crsReteta
		ENDIF 
		
		RELEASE poReteta
	ENDPROC

	PROCEDURE grid_web_reteta.Init
		This.SetAll("DynamicBackColor","IIF(cant_nec > cant_in_stoc, RGB(255,113,113),IIF(cante > cant_in_stoc, RGB(255,205,155)," + ;
			"IIF(adaugat = 1,RGB(255,255,204), RGB(255,255,255))))", "Column")
		This.cCante.DynamicBackColor = "IIF(cant_nec > cant_in_stoc, RGB(255,113,113),IIF(cante > cant_in_stoc, RGB(255,205,155),RGB(187,235,255)))"
	ENDPROC

	PROCEDURE grid_web_retetar.Init
		This.SetAll("DynamicBackColor","IIF(cant_nec > cant_in_stoc, RGB(255,113,113),IIF(cante > cant_in_stoc, RGB(255,205,155)," + ;
			"IIF(adaugat = 1,RGB(255,255,204), RGB(255,255,255))))", "Column")
	ENDPROC

	PROCEDURE Lb_titlu_alb_b121.Init
		IF TYPE('oxset.nume_set') # 'U'
			this.Caption = PROPER(ALLTRIM(oxset.nume_set))
		ENDIF 
	ENDPROC

	PROCEDURE txtDataF.Valid
		pdDataF = this.value 
	ENDPROC

	PROCEDURE txtDataI.Valid
		pdDataI = this.value 
	ENDPROC

	PROCEDURE _shape1.DblClick
		IF thisform.WindowState = 2
			thisform.WindowState = 0
		ELSE 
			thisform.WindowState = 2 
		ENDIF 
	ENDPROC

ENDDEFINE

DEFINE CLASS restnir_retetar_cum 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="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboListe" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cbo_idGest_inProd" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_nec.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_nec.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_in_stoc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCant_in_stoc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cUM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cUM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCanter.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCanter.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCanteM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCanteM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCante.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cCante.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDataIn.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.cDataIn.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataI" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCodmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCodmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_vand.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_vand.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cPretvtva.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cPretvtva.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_produsa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_produsa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_ramasa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_ramasa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cNr_crt.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cNr_crt.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_de_produs.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.cCant_de_produs.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ck_cant" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: actualizeaza_politici_preturi
		*m: assign_analitic
		*m: completeaza_actactan
		*m: completeaza_rultemp
		*m: do_modifica_nrportii
		*p: ccrsretete
		*p: ccrsvanzari
		*p: cfrm_ceredate
		*p: cobj
		*p: ncantveche
		*p: nidprodus
		*p: npretvtva
		*p: ntipgest
		*p: nvaloareveche
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton3 = 
		cbuton4 = Ct_grid_order1.But_sterge1;but_reface1
		ccrsretete = cweb_retete
		ccrsvanzari = cweb_vanzari
		cfrm_ceredate = 
		cgridsortlist = grid_web_retetar,grid_web
		cobj = 
		DoCreate = .T.
		Height = 572
		lactiv1 = .T.
		lactiv3 = .T.
		lactiv4 = .T.
		Name = "restnir_retetar_cum"
		ncantveche = 0
		nidprodus = 0
		npretvtva = 0
		ntipgest = 0
		nvaloareveche = 0
		Width = 946
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="ccrsvanzari" display="cCrsVanzari"/>
			<memberdata name="ccrsretete" display="cCrsRetete"/>
			<memberdata name="nvaloareveche" display="nValoareVeche"/>
			<memberdata name="nvaloarenoua" display="nValoareNoua"/>
			<memberdata name="ncantveche" display="nCantVeche"/>
		</VFPData>
		_shape1.Anchor = 11
		_shape1.Height = 30
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Tag = ""
		_shape1.Top = -1
		_shape1.Width = 949
		_shape1.ZOrderSet = 0
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 820
		_shape2.Name = "_shape2"
		_shape2.Tag = "MOVABLE"
		_shape2.Top = 0
		_shape2.Width = 127
		_shape2.ZOrderSet = 1
		Lb_titlu_alb_b121.Anchor = 3
		Lb_titlu_alb_b121.FontName = "Comic Sans MS"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Height = 20
		Lb_titlu_alb_b121.Left = 4
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 18
		Lb_titlu_alb_b121.Top = 6
		Lb_titlu_alb_b121.Width = 41
		Lb_titlu_alb_b121.ZOrderSet = 2
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 914
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 14
		BUT_TERMIN1.Tag = ""
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 32
		BUT_TERMIN1.ZOrderSet = 5
		Gridsort1.Left = 144
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 1
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 9, ;
		Left = 854, ;
		Name = "But_excel1", ;
		TabIndex = 12, ;
		ToolTipText = "Materii prime cumulate insuficiente in stoc (CTRL+E)", ;
		Top = 1, ;
		Visible = .T., ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Anchor = 9, ;
		Left = 823, ;
		Name = "But_listare1", ;
		TabIndex = 11, ;
		Top = 1, ;
		Visible = .T., ;
		ZOrderSet = 21
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 9, ;
		Left = 884, ;
		Name = "But_renunt1", ;
		TabIndex = 13, ;
		Tag = "", ;
		Top = 1, ;
		ZOrderSet = 4
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_reset1' AS but_reset WITH ;
		Left = 550, ;
		Name = "But_reset1", ;
		Top = 78
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cbo_idGest_inProd' AS combobox WITH ;
		Anchor = 9, ;
		ColumnCount = 5, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,40,25,15,100", ;
		FontName = "Arial Narrow", ;
		Height = 24, ;
		Left = 783, ;
		Name = "cbo_idGest_inProd", ;
		RowSource = "crsGestiuni.nume_gestiune,cgest,cont,acont,nume_tip", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 10, ;
		Top = 36, ;
		Width = 147, ;
		ZOrderSet = 10
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cboListe' AS combobox WITH ;
		Anchor = 3, ;
		ColumnLines = .F., ;
		Enabled = .F., ;
		FontName = "Arial Narrow", ;
		Format = "", ;
		Height = 24, ;
		Left = 360, ;
		Name = "cboListe", ;
		TabIndex = 5, ;
		Top = 36, ;
		Width = 235, ;
		ZOrderSet = 9
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'ck_cant' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "Doar cele cu cantitatea care se produce diferita de 0", ;
		FontName = "Arial Narrow", ;
		Left = 311, ;
		Name = "ck_cant", ;
		Top = 85
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 3, ;
		Height = 27, ;
		Left = 233, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 4, ;
		Top = 35, ;
		Width = 49, ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grid_web' AS _grdrow WITH ;
		Anchor = 7, ;
		ColumnCount = 8, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 456, ;
		HighlightStyle = 2, ;
		Left = 9, ;
		Name = "grid_web", ;
		Panel = 1, ;
		RecordSource = "cWeb_vanzari", ;
		TabIndex = 6, ;
		Top = 109, ;
		Width = 595, ;
		ZOrderSet = 20, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "codmat", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cCodmat", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 44, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "denumire", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cDenumire", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 144, ;
		Column3.ColumnOrder = 5, ;
		Column3.ControlSource = "cant_vand", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(7,gnPCant)), ;
		Column3.Name = "cCant_vand", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 51, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "pretvtva", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(10,gnPPretV)), ;
		Column4.Name = "cPretvtva", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 62, ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "cant_produsa", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "RK", ;
		Column5.InputMask = (get_mask(7,gnPCant)), ;
		Column5.Name = "cCant_produsa", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 66, ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "cant_ramasa_de_scazut", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.InputMask = (get_mask(7,gnPCant)), ;
		Column6.Name = "cCant_ramasa", ;
		Column6.ReadOnly = .T., ;
		Column7.ColumnOrder = 1, ;
		Column7.ControlSource = "nr_crt", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.InputMask = "9999", ;
		Column7.Name = "cNr_crt", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 36, ;
		Column8.ControlSource = "cant_de_produs", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.InputMask = (get_mask(10,gnPCant)), ;
		Column8.Name = "cCant_de_produs"
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web.cCant_de_produs.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. care se produce", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_de_produs.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_produsa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. produsa in perioada", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_produsa.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_ramasa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. ramasa de scazut", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.cCant_ramasa.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.cCant_vand.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cant. vanduta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cCodmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod mat.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cNr_crt.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.crt.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.cPretvtva.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret de vanz. (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 8, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 456, ;
		HighlightStyle = 2, ;
		Left = 613, ;
		Name = "grid_web_retetar", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "cWeb_vanzari_retetar", ;
		TabIndex = 8, ;
		Top = 109, ;
		Width = 311, ;
		ZOrderSet = 14, ;
		Column1.BackColor = 255,255,255, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cDenumire", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 95, ;
		Column2.BackColor = 255,255,255, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "cant_nec", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Format = "rk", ;
		Column2.InputMask = (get_mask(10,gnPCant)), ;
		Column2.Name = "cCant_nec", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 45, ;
		Column3.BackColor = 255,255,255, ;
		Column3.ControlSource = "cant_in_stoc", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(10,gnPCant)), ;
		Column3.Name = "cCant_in_stoc", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 44, ;
		Column4.BackColor = 255,255,255, ;
		Column4.ControlSource = "um", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Name = "cUM", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 29, ;
		Column5.ControlSource = "canter", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPCant)), ;
		Column5.Name = "cCanter", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 59, ;
		Column6.ControlSource = "cantem", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.InputMask = (get_mask(10,gnPCant)), ;
		Column6.Name = "cCanteM", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 61, ;
		Column7.ControlSource = "cante", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.InputMask = (get_mask(10,gnPCant)), ;
		Column7.Name = "cCante", ;
		Column7.ReadOnly = .F., ;
		Column8.ControlSource = "datain", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.Name = "cDataIn", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 49
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web_retetar.cCant_in_stoc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cCant_nec.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate necesara", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cCante.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate care se scoate", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_retetar.cCante.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web_retetar.cCanteM.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Ajustari fata de reteta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cCanter.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate din reteta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cDataIn.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data intrarii in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.cUM.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 11, ;
		Name = "Label1", ;
		TabIndex = 20, ;
		Top = 39, ;
		Width = 39, ;
		ZOrderSet = 6
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "-", ;
		Height = 17, ;
		Left = 137, ;
		Name = "Label2", ;
		TabIndex = 21, ;
		Top = 40, ;
		Width = 6, ;
		ZOrderSet = 13
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Lista de preturi", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 288, ;
		Name = "Label3", ;
		TabIndex = 22, ;
		Top = 39, ;
		Width = 62, ;
		ZOrderSet = 18
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Materii prime cumulate", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 615, ;
		Name = "Label5", ;
		TabIndex = 16, ;
		Top = 86, ;
		Width = 96, ;
		ZOrderSet = 8
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label8' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Gestiunea in care intra produsele", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 644, ;
		Name = "Label8", ;
		TabIndex = 24, ;
		Top = 39, ;
		Width = 138, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label9' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Vanzari din gestiunea de marfuri aleasa", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 12, ;
		Name = "Label9", ;
		TabIndex = 17, ;
		Top = 85, ;
		Width = 165, ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDataF' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataF", ;
		FontName = "Arial Narrow", ;
		Format = "K", ;
		Height = 23, ;
		Left = 144, ;
		Name = "txtDataF", ;
		TabIndex = 2, ;
		Top = 37, ;
		Width = 81, ;
		ZOrderSet = 16
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtDataI' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataI", ;
		FontName = "Arial Narrow", ;
		Format = "K", ;
		Height = 23, ;
		Left = 53, ;
		Name = "txtDataI", ;
		TabIndex = 1, ;
		Top = 37, ;
		Width = 81, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE actualizeaza_grid1
		Local lcCursorTemp
		save_grid_tag(Thisform.grid_web)
		lcSel = [{call pack_grestaurant.vanzari_stoc(?pnIdGest_InMarf,] + ;
			[?pdDataI,?pdDataF,?gnAn,?gnLuna,?gnIdSucursala)}]
		lnSucces = goExecutor.oExecute(lcSel, Thisform.cCrsVanzari)
		If lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		restore_grid_tag(Thisform.grid_web)
		
		lcCursorTemp = 'crsTempRet'
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
		lcSel = [{call pack_grestaurant.vanzari_retetar_cumulat(?poAct.id_gestiune,?pnIdGest_InMarf,] + ;
			[?pdDataI,?pdDataF,?gnAn,?gnLuna,?gnIdUtil,?gnIdSucursala)}]
		lnSucces = goExecutor.oExecute(lcSel, lcCursorTemp)
		If lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			Return
		Endif
		
		copiaza_structura_cursor(lcCursorTemp,Thisform.cCrsRetete)
		If Reccount(lcCursorTemp) > 0
			Select (Thisform.cCrsRetete)
			Append From Dbf(lcCursorTemp)
		Endif
		If Used(lcCursorTemp)
			Use In (lcCursorTemp)
		Endif
		
		Thisform.actualizeaza_grid2()
		Thisform.grid_web.Refresh()
		Thisform.grid_web.SetFocus()
	ENDPROC

	PROCEDURE actualizeaza_grid2
		Local lcCursor,lcCursorReteta
		lcCursor = Thisform.grid_web_retetar.RecordSource
		save_grid_tag(Thisform.grid_web_retetar)
		If Used(lcCursor)
			Select a.id_material,a.id_articol,a.denumire,a.datain,;
				Cast(Nvl(b.cant_nec,0) As N(10,gnPCant)) As cant_nec,;
				Cast(Nvl(b.canter,0) As N(10,gnPCant)) As canter,;
				a.cant_in_stoc, a.um, a.adaugat, ;
				CAST(a.cantem As N(10,gnPCant)) As cantem,;
				Cast(Nvl(b.canter,0)+a.cantem As N(10,gnPCant)) As cante ;
				FROM (lcCursor) a ;
				LEFT Join (Select id_material, id_articol,denumire, ;
				SUM(cant_nec) As cant_nec, ;
				CAST(Sum(cante) As N(10,gnPCant)) As canter,cant_in_stoc,um, adaugat ;
				FROM (Thisform.cCrsRetete) ;
				WITH (Buffering = .T.) ;
				Group By id_material, id_articol, denumire, cant_in_stoc, um, adaugat, datain) b ;
				on a.id_material = b.id_material And a.id_articol = b.id_articol AND b.adaugat = 0;
				Order By b.denumire,b.id_material ;
				INTO Cursor (lcCursor) readwrite
		Else
			Select id_material, id_articol, denumire,datain, ;
				SUM(cant_nec) As cant_nec, ;
				CAST(Sum(cante) As N(10,gnPCant)) As canter, ;
				cant_in_stoc, um, adaugat,;
				CAST(0 As N(10,gnPCant)) As cantem,;
				CAST(Sum(cante) As N(10,gnPCant)) As cante ;
				FROM (Thisform.cCrsRetete) ;
				WITH (Buffering = .T.) ;
				Group By id_material, id_articol, denumire, cant_in_stoc, um, adaugat, datain ;
				ORDER By denumire,id_material ;
				INTO Cursor (lcCursor) readwrite
		Endif
		restore_grid_tag(Thisform.grid_web_retetar)
		Thisform.grid_web_retetar.Refresh()
		Release lcCursor,lnIdArticol,lnCantitate,lcDenumire,lcFiltru,lnIdArticol
		
	ENDPROC

	PROCEDURE actualizeaza_politici_preturi
		Lparameters tnTip
		If tnTip = 0
			Thisform.cboListe.ColumnCount =	0
			Thisform.cboListe.ColumnWidths = []
			Thisform.cboListe.RowSource	= []
			Thisform.cboListe.RowSourceType	=	0
			Thisform.cboListe.Style	= 0
			Thisform.cboListe.Enabled = .F.
			If Used('cListePreturi')
				Use In cListePreturi
			Endif
		Else
			If Used('cListePreturi')
				Use In cListePreturi
			Endif
			Create Cursor cListePreturi(nume_lista_preturi C(200),id_pol N(10))
			Insert Into cListePreturi(nume_lista_preturi,id_pol) Values('<TOATE>',-9999)
			Insert Into cListePreturi(nume_lista_preturi,id_pol) Select Distinct Substr(nume_lista_preturi,1,200),id_pol From cweb_vanzari Order By 1
		
			If Reccount('cListePreturi') > 2
				Select cListePreturi
				Go Top
				Thisform.cboListe.ColumnCount	=	2
				Thisform.cboListe.ColumnWidths = [200,0]
				Thisform.cboListe.RowSource	= [cListePreturi.nume_lista_preturi,id_pol]
				Thisform.cboListe.RowSourceType	=	2
				Thisform.cboListe.Style	= 2
				Thisform.cboListe.Enabled = .T.
				Thisform.cboListe.Value = cListePreturi.nume_lista_preturi
			Endif
		Endif
	ENDPROC

	PROCEDURE assign_analitic
		PARAMETERS tcCont,pcAct,pcRul
		
		PRIVATE pcCont,pcAct,pcRul,pParamP,pParamS
		STORE 0 TO pParamP,pParamS
		lcAnalitic = ''
		lcAlias = ALIAS()
		
		pcCont = ALLTRIM(tcCont)
		
		lcSel = [SELECT * from ] + gcs + [.config_analitice WHERE cont = ?pcCont]
		lcCursor = 'crs_cfg_ana'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		IF lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_cfg_ana')=0
				USE IN crs_cfg_ana
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			SELECT crs_cfg_ana
			SCATTER NAME ocfg
			lcCampPrefix = NVL(ALLTRIM(ocfg.camp_leg_prefix),'')
			lcCampSufix = NVL(ALLTRIM(ocfg.camp_leg_sufix),'')
			
			IF !EMPTY(lcCampPrefix)
				IF TYPE('&pcRul..'+lcCampPrefix) # 'U'
					pParamP = &pcRul..&lcCampPrefix
				ELSE 
					IF TYPE('&pcAct..'+lcCampPrefix) # 'U'
						pParamP = &pcAct..&lcCampPrefix
					ENDIF 
				ENDIF 
			ENDIF 
			
			IF !EMPTY(lcCampSufix)
				IF TYPE('&pcRul..'+lcCampSufix) # 'U'
					pParamS = &pcRul..&lcCampSufix 
				ELSE 
					IF TYPE('&pcAct..'+lcCampSufix) # 'U'
						pParamS = &pcAct..&lcCampSufix 
					ENDIF 
				ENDIF 
			ENDIF 
		
			lcSel = [{call fconturi_analitice(?gcs,?pcCont,0,?pParamP,?pParamS)}]
			lcCursor = 'crs_analitice'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		&& iau Primul Simbol Analitic din Tabel - ordonat pt ca e selectat cu Distinct
		IF lnSucces > 0
			SELECT crs_analitice
			GO top
			lcAnalitic = ALLTRIM(acont)
		ENDIF 
		
		&& verificare analiticului cu Planul de Conturi
		IF lnSucces > 0
			lcSel = [SELECT cont,acont from ] + gcs + [.vplcont_analitic WHERE cont = ?pcCont and acont = ?lcAnalitic and an = ?gnAn ]
			lcCursor = 'crs_verific'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_verific')=0
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF USED('crs_cfg_ana')
			USE IN crs_cfg_ana
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		IF USED('crs_analitice')
			USE IN crs_analitice
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		
		IF lnSucces < 0
			lcAnalitic = ''
		ENDIF 
		
		SELECT (lcAlias)
		RETURN lcAnalitic
		
	ENDPROC

	PROCEDURE completeaza_actactan
		Local lcSelRul, lcContTr, lcAcontTr, lcRul, lcSql, lcCursor, lnSucces, lcCant
		Store '' To lcContTr, lcAcontTr
		
		llSucces = This.completeaza_rultemp()
		If !llSucces
			Return .F.
		Endif
		
		Local lnRecno
		lnRecno = 0
		
		*** completez tabela ACTACTAN
		If Type('oitem') = 'O'
			If Pemstatus(oitem,'adunadate',5)
				oitem.adunadate()
			Endif
		ENDIF
		
		&& NOTE
		Select * From XNOTE Where id_set = oset.id_set Into Cursor crsNota
		
		lcField = ''
		Select xact
		Go Top
		
		For i = 1 To Fcount()
			If Upper(Alltrim(Evaluate(Field(i)))) = 'SUMA'
				lcField = Field(i)
				Exit
			Endif
		Endfor
		
		If Empty(lcField)
			Return .T.
		Endif
		
		Private pnBazaBon,pnBazaNir,pnTvaVanzIn,pnAdaosVanzIn,pnBazaVanz
		Store 0 To pnBazaBon,pnBazaNir,pnTvaVanzIn,pnAdaosVanzIn,pnBazaVanz
		
		Select cweb_vanzari
		Calculate Sum(Round(pret*cant_de_produs,gnPc)),Sum(Round(tvav*cant_de_produs,gnPc)),;
			Sum(Round(pretftva*cant_de_produs,gnPc)) ;
			TO pnBazaNir,pnTvaVanzIn,pnBazaVanz
		
		Select rul_temp
		Calculate Sum(Round(Pret*cante, gnPC)) To pnBazaBon For Cont = '301'
		
		pnAdaosVanzIn = pnBazaVanz - pnBazaNir
		
		Select actactan
		Scatter Name loActactan
		Replace suma With pnBazaBon FOR scd = '601' AND scc = '301'
		Replace suma WITH pnBazaNir,id_gestin With pnIdGest_InProd For scd = '345' And scc = '711'
		Replace suma WITH pnBazaNir,id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InProd For scd = '371' And scc = '345'
		If Thisform.ntipgest = 6
			Replace suma With pnAdaosVanzIn, id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InMarf For scd = '371' And scc = '378'
			Replace suma With pnTvaVanzIn,id_gestin With pnIdGest_InMarf,id_gestout With pnIdGest_InMarf For scd = '371' And scc = '4428'
		Endif
		
		Select Distinct acont From rul_temp Where Cont = '301' Into Cursor cAcont301
		Select cAcont301
		Scan
			lnValAchizitie = 0
			lcAcont = NVL(acont,'')
			Select rul_temp
			Calculate Sum(Round(Pret*cante, gnPC)) To lnValAchizitie For Cont = '301' And NVL(acont,'') = lcAcont
			Select actactan
			Locate For scc = '301' And Empty(NVL(ascc,''))
			If Found()
				Replace suma With lnValAchizitie, ascc With lcAcont
			Else
				Select actactan
				Locate For scc = '301'
				Scatter Name lo301
				Append Blank
				Gather Name lo301
				Replace suma With lnValAchizitie, ascc With lcAcont
			Endif
			Select cAcont301
		Endscan
		
		Select rul_temp
		Replace All dataact With loActactan.dataact, ;
			nnir With loActactan.nnir, ;
			id_sectie With loActactan.id_sectie, ;
			id_responsabil With loActactan.id_responsabil, ;
			id_lucrare With loActactan.id_lucrare
		If Used('crsNota')
			Use In crsNota
		Endif
		
		&& ordonez notele contabile in ACTACTAN
		Select actactan
		Sum suma To lnSume
		
		If lnSume <> 0
			lcCondDele = [!(suma = 0 and !(((left(scd,1) = '3' and left(scc,2) = '40') OR (left(scd,2) = '41' and left(scc,1) = '7')) AND proc_tva # 1))]
		Else
			lcCondDele = [suma = 0 AND nr_nota = 1 ]
		Endif
		
		Select * From actactan Into Cursor crsActActan Where &lcCondDele Or Inlist(id_set, 89, 210, 211, 212) Order By nr_nota NOFILTER Readwrite
		
		Select actactan
		Delete From actactan
		Append From Dbf('crsactactan')
		If Used('crsactactan')
			Use In crsActActan
		Endif
		
		&& completare analitice
		Select actactan
		Scan For Empty(Nvl(ascd,''))
			Scatter Name loActactan
			If Type('loActactan.cont') = 'U'
				x = AddProperty(loActactan,'cont',loActactan.scd)
			Endif
			If oset.model = 2 And Type('loActactan.id_gestiune') = 'U'              && NIR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestin)
			Endif
			If Inlist(oset.model, 3, 4) And Type('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestout)
			Endif
			loActactan.ascd = This.assign_analitic(loActactan.scd,This.cobj,'loActactan')
			Replace ascd With loActactan.ascd
			Select actactan
		Endscan
		
		Select actactan
		Scan For Empty(Nvl(ascc,''))
			Scatter Name loActactan
			If Type('loActactan.cont') = 'U'
				x = AddProperty(loActactan,'cont',loActactan.scc)
			Endif
			If oset.model = 2 And Type('loActactan.id_gestiune') = 'U'              && NIR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestin)
			Endif
			If Inlist(oset.model, 3, 4) And Type('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = AddProperty(loActactan,'id_gestiune',loActactan.id_gestout)
			Endif
			loActactan.ascc = This.assign_analitic(loActactan.scc,This.cobj,'loActactan')
			Replace ascc With loActactan.ascc
			Select actactan
		Endscan
		
		Select actactan
		Locate For scd = '371' And scc = '345'
		If Found()
			lcAscd = ascd
			Select rul_temp
			Replace All acont With lcAscd For Cont = '371' And cante <> 0 And cant = 0
		Endif
		
		If Thisform.ntipgest = 6
			Select actactan
			Locate For scd = '371' And scc = '378'
			If Found()
				lcAscd = ascd
				Select rul_temp
				Replace All acont With lcAscd For Cont = '371' And cante = 0 And cant <> 0
				Select actactan
				Replace id_gestout With 0 For scd = '371' And scc = '378'
			Endif
		Endif
		
		*!*	Select actactan
		*!*	Replace id_gestin With pnIdGest_InMarf, id_gestout With pnIdGest_InProd For scd = '371' And scc = '345'
		
		If Type('loActactan') = 'O'
			Release loActactan
		Endif
		
		Select actactan
		Go Top
		
		Return .T.
		
	ENDPROC

	PROCEDURE completeaza_rultemp
		&& completez RUL_TEMP
		lcProduse = This.grid_web.RecordSource
		lcMateriale = This.grid_web_retetar.RecordSource
		
		If Used('rul_temp')
			Use In rul_temp
		Endif
		
		* lcRul = ALLTRIM(THIS.osel_dr.cfrom)
		lcSql = [select v.*, v.id_gestiune as id_gestin, v.nume_gestiune as gestin, v.id_gestiune as id_gestout,] + ;
			[v.nume_gestiune as gestout, 0 as nuInConturiX from ] + gcS + [.vrul v where 1=2]
		lcCursor = [rul_temp]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		Endif
		
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		
		lcSql = [select id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont, datain, SUM(cants + cant - cante) as stoc ] + ;
			[from stoc where an = ] + Transform(gnAn) + [ and luna = ] + Transform(gnLuna) + ;
			[ and id_gestiune in (] + Transform(poAct.id_gestiune)+ [) and NVL(id_rul_aux,0) = 0 ] + gcCondSucursala + ;
			[ group by id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont, datain order by datain]
		lcCursor = [crsStocActual1]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		Endif
		
		If Used("crsStocActual")
			Use In crsStocActual
		Endif
		
		Select * From crsStocActual1 ;
			WITH (Buffering = .T.) ;
			INTO Cursor crsStocActual ;
			READWRITE
		
		Select * From crsStocActual1 ;
			WITH (Buffering = .T.) ;
			INTO Cursor crsStocActual_2 ;
			READWRITE
		
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		
		If Used("crsMateriale")
			Use In crsMateriale
		Endif
		*!*	SELECT id_material AS id_articol, IIF(cant_nec < cant_in_stoc, cant_nec, cant_in_stoc) AS cante ;
		*!*		FROM (lcMateriale) ;
		*!*		WITH (buffering = .t.) ;
		*!*		INTO CURSOR crsMateriale ;
		*!*		READWRITE
		
		Select id_articol, cante ;
			FROM (lcMateriale) ;
			WITH (Buffering = .T.) ;
			where cante > 0 ;
			INTO Cursor crsMateriale ;
			READWRITE
		
		Select crsMateriale
		Scan
			lnCantRamas = cante
			lnIdArticol = id_articol
			lnCantInit = cante
			*!*		lcMaterial = ALLTRIM(denumire)
			Select crsStocActual
			Locate For id_articol = lnIdArticol And stoc > 0
			Do While Found() And lnCantRamas > 0
				lcCont = Cont
				lcAcont = Nvl(acont,'')
		
				lnCante = Min(lnCantRamas, stoc)
				lnCantRamas = lnCantRamas - lnCante
				lnPret = Pret
				lnIdGestiune = id_gestiune
		
				*!*		INSERT INTO test (material, id_mat, cant_nec, cante, cantramas, stoc, pret) VALUES (lcMaterial, lnIdArticol, lnCantInit, lnCante, lnCantRamas, crsStocActual.stoc, lnPret)
				Replace stoc With stoc - lnCante
		
				If Left(lcCont,3) <> '371'
					Select rul_temp
					Scatter Name loRul Blank
					With loRul
						.id_articol = lnIdArticol
						*.id_gestout = lnIdGestiune
						.id_gestiune = lnIdGestiune
						.cante = lnCante
						.Pret = Round(lnPret, gnPpret)
						.Cont = lcCont
						.acont = lcAcont
					Endwith
					Select rul_temp
					Append Blank
					Gather Name loRul
				Endif
		
				Select crsStocActual
		*!*			Locate For id_articol = lnIdArticol And stoc > 0 And lnCantRamas > 0
				CONTINUE 
			Enddo
			Select crsMateriale
		Endscan
		
		If Used("crsMateriale")
			Use In crsMateriale
		Endif
		
		**********************************************************************
		* 345 = 711 - intrare produs la pret de achizitie materiale componente
		* nuProdus ex.: chifle, banane - pe care le cumpara direct ca marfa, si nu devin produse
		**********************************************************************
		Select id_articol, cant_de_produs As cant, Pret, tvav, pretftva, proc_tvav, ;
			0 As nuProdus ;
			FROM (lcProduse) ;
			WITH (Buffering = .T.) ;
			WHERE cant_de_produs > 0 ;
			INTO Cursor crsProduseIesiri ;
			READWRITE
		
		Select crsProduseIesiri
		Scan
			Scatter Name loProdus
			lnIdArticol = id_articol
		*!*		lnPretvtva = pretvtva
			lnCant = cant
			Select * From (Thisform.cCrsRetete) ;
				WHERE id_produs = lnIdArticol ;		&&	And pretvtva = lnPretvtva
			Into Cursor cCalcReteta
		
			lnPretCalc = 0
			lnComponente = 0
			lnComponenteGasite = 0
			Select cCalcReteta
			Scan
				lnComponente = lnComponente + 1
				lnCantRamas = cante
				lnId_material = id_material
				lnCantInit = cante
				Select crsStocActual_2
				Locate For id_articol = lnId_material And stoc > 0
				Do While Found() And lnCantRamas > 0
					If Left(Cont,3) = '371'
						lnComponenteGasite = lnComponenteGasite + 1
					Endif
					lnCante = Min(lnCantRamas, stoc)
					lnCantRamas = lnCantRamas - lnCante
					lnPret = Pret
					Replace stoc With stoc - lnCante
		
					lnPretCalc = Round(lnPretCalc + Round(lnCante * lnPret, gnPpret), gnPpret)
					*!*				Select crsStocActual_2
					*!*				Locate For id_articol = lnId_material And stoc > 0 And lnCantRamas > 0
					Continue
				Enddo
		
				Select cCalcReteta
			Endscan
		
			If Used("cCalcReteta")
				Use In cCalcReteta
			Endif
		
			If lnComponenteGasite < lnComponente
				&& daca toate componentele sunt in stoc pe contul 371, nu mai scriu in rul_temp
				Select rul_temp
				Append Blank
				Gather Name loProdus FIELDS LIKE id_articol,cant,pret
		*!*			Replace Pret With Round(lnPretCalc/lnCant, gnPpret), Cont With '345', id_gestiune With pnIdGest_InProd
				Replace Cont With '345', id_gestiune With pnIdGest_InProd
			Else
				Select crsProduseIesiri
				Replace nuProdus With 1
			Endif
		
		*!*		Select crsProduseIesiri
		*!*		Replace Pret With Round(lnPretCalc/lnCant, gnPpret)
		
			Select crsProduseIesiri
		Endscan
		
		**********************************************************************
		* 371 = 345 - iesire produs
		**********************************************************************
		Select crsProduseIesiri
		Scan For nuProdus = 0
			Scatter Name loProdus
		
			Select rul_temp
			Append Blank
			Gather Name loProdus FIELDS LIKE id_articol, pret
			Replace cante With Round(loProdus.cant,gnPCant), ;
				CONT With '345', ;
				id_gestiune With pnIdGest_InProd
		
			Select rul_temp
			Append Blank
			Gather Name loProdus Fields Like id_articol, cant, Pret
			Replace Cont With '371', ;
				id_gestiune With pnIdGest_InMarf
			If Thisform.ntipgest = 6
				Replace pretv With loProdus.pretftva, ;
					proc_tvav WITH loProdus.proc_tvav,;
					adaos With loProdus.pretftva - loProdus.pret, ;
					adaos_tva With Round(Round(loProdus.pretftva-loProdus.Pret,max(gnPpret,gnPPretV))*Iif(proc_tvav <> 0, proc_tvav-1,0),max(gnPpret,gnPPretV)), ;
					tvav With tvav
			Endif
			Select crsStocActual
		Endscan
		
		If Used("crsStocActual")
			Use In crsStocActual
		Endif
		If Used("crsStocActual1")
			Use In crsStocActual1
		Endif
		If Used("crsProduseIesiri")
			Use In crsProduseIesiri
		Endif
	ENDPROC

	PROCEDURE Destroy
		If Used('cListePreturi')
			Use In cListePreturi
		Endif
		
		If Used(Thisform.cCrsVanzari)
			Use In (Thisform.cCrsVanzari)
		Endif
		
		If Used(Thisform.cCrsRetete)
			Use In (Thisform.cCrsRetete)
		Endif
		
		If Used("cWeb_vanzari_retetar")
			Use In cWeb_vanzari_retetar
		Endif
		
		
	ENDPROC

	PROCEDURE do_adauga
		*!*	Local lnId_Produs,lnCantitate,loas,lnAdaugat 
		*!*	loas = Createobject("frm_alege_din_stoc")
		*!*	loas.lb_titlu_alb_b121.Caption = "STOC"
		*!*	Select xsets
		*!*	Locate For id_set = 106 && tnIdSet
		*!*	Scatter Name oSet
		*!*	*!*	modificare JC/JV 2007
		*!*	If gnNeplatitoare_tva = 1
		*!*		oSet.id_jtax = oSet.id_jtaxn
		*!*		oSet.id_jnetax = oSet.id_jtaxn
		*!*	Endif
		*!*	*!*	modificare JC/JV 2007	^
		*!*	lFactura = oSet.factura
		*!*	lAdaos = oSet.adaos
		*!*	lDiscount = oSet.discount
		*!*	lcTipFrm = Upper(oSet.explicatia)
		*!*	llGestout = .F.
		
		*!*	Select selectii
		*!*	Locate For id_sel = oSet.id_selSt
		*!*	If Found()
		*!*		Scatter Name ost Memo
		*!*	Else
		*!*		amessagebox('NECONFIGURAT!',48,'Atentie!')
		*!*		Return 2 && renunt
		*!*	Endif
		
		*!*	lcSelSt = Alltrim(ost.cselect) + [ from ] + gcs + [.] + Alltrim(ost.cfrom) + [ where ] + Alltrim(ost.filtru)
		*!*	lcSchemaSt = Alltrim(ost.cschema)
		
		*!*	With loas.ct_grid_search1
		*!*		.cselect = lcSelSt
		*!*		.cschema = lcSchemaSt
		*!*		.cTitlu_coloane = Alltrim(ost.titlu_col)
		*!*		.cNume_coloane = Alltrim(ost.nume_col)
		*!*		.cMask = Alltrim(ost.mask_col)
		*!*		.cFiltruOriginal = Strtran(Alltrim(Evaluate(ost.filtruorig)),[<>],[>]) +  [ and id_gestiune = ?poAct.id_gestiune ]
		*!*		.cFiltru = Alltrim(ost.filtru)
		*!*		.cOrder = Alltrim(ost.ordine)
		*!*		.cTitlu = Alltrim(ost.titlu_grid)
		*!*		.cb_tx_gestout.Visible = llGestout
		*!*		.but_nou1.Visible = llAdMod
		*!*		*	.but_modifica1.VISIBLE = llAdMod
		*!*	Endwith
		*!*	loas.Show(1)
		
		*!*	If buton = 2
		*!*		Return
		*!*	Endif
		
		*!*	Select cursor_curent1
		*!*	If Reccount() > 0
		*!*		Scatter Name loArticol
		*!*		Select (Thisform.cCrsRetete)
		*!*		lnId_Produs = id_produs
		*!*		Locate For id_material = loArticol.id_articol
		*!*		If !Found()
		*!*			lnAdaugat = 1
		*!*			Append Blank
		*!*			Replace id_produs With lnId_Produs, ;
		*!*				id_material With loArticol.id_articol, ;
		*!*				den_material With loArticol.denumire, ;
		*!*				cant_nec With 0, ;
		*!*				cant_in_stoc With loArticol.cantitate, ;
		*!*				um With loArticol.um, ;
		*!*				adaugat With lnAdaugat
		*!*			Select (Thisform.grid_web_retetar.RecordSource)
		*!*			Locate For id_material = loArticol.id_articol
		*!*			If Found()
		*!*				lnCantitate = cant_nec
		*!*			Else
		*!*				lnCantitate = 0
		*!*			Endif
		*!*			Select (Thisform.cCrsRetete)
		*!*			Replace cant_nec_cum With lnCantitate
		*!*		Else
		*!*			lnAdaugat = 0
		*!*		Endif
		*!*		Thisform.actualizeaza_grid3()
		*!*		Select (Thisform.grid_web_retetar.RecordSource)
		*!*		Locate For id_material = loArticol.id_articol And adaugat = lnAdaugat
		*!*		Thisform.grid_web_retetar.Refresh()
		*!*		Thisform.grid_web_reteta.Refresh()
		*!*		Thisform.grid_web_reteta.cCante.SetFocus()
		*!*	Endif
	ENDPROC

	PROCEDURE do_cauta
		Do Case
			Case Empty(gcGestPermis)
				AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
				Return
			Case Empty(pdDataI)
				AMESSAGEBOX("Completati data initiala !",0+48,"Atentie")
				Thisform.txtDataI.SetFocus()
				Return
			Case Empty(pdDataF)
				AMESSAGEBOX("Completati data finala !",0+48,"Atentie")
				Thisform.txtDataF.SetFocus()
				Return
				*!*		CASE pdDataI < DATE(gnAn,gnLuna,1)
				*!*			amessagebox("Data initiala trebuie sa fie din luna curenta!",0+48,"Atentie")
				*!*			Thisform.txtDataI.SetFocus()
				*!*			RETURN
				*!*		CASE pdDataF >= GOMONTH(DATE(gnAn,gnLuna,1),1)
				*!*			amessagebox("Data finala trebuie sa fie din luna curenta!",0+48,"Atentie")
				*!*			Thisform.txtDataF.SetFocus()
				*!*			RETURN
			Otherwise
				pcPerioada = Dtoc(pdDataI) + " - " + Dtoc(pdDataF)
		Endcase
		
		Thisform.actualizeaza_politici_preturi(0)
		Thisform.actualizeaza_grid1()
		IF RECCOUNT(Thisform.cCrsVanzari) > 0
			Update (Thisform.cCrsVanzari) Set nuInRetetar = 1 Where id_articol Not In (Select Distinct id_produs From (Thisform.cCrsRetete) WHERE !ISNULL(id_produs))
			Select (Thisform.cCrsVanzari)
			Locate For nuInRetetar = 1
			If Found()
				AMESSAGEBOX("Exista produse care nu au definita fisa tehnologica!",0+48,"Definiti fisa tehnologica!")
			ELSE
				GO top
			Endif
		
			Thisform.actualizeaza_politici_preturi(1)
		*!*		Thisform.grid_web.AfterRowColChange()
		ELSE
			amessagebox("Nu exista rezultate pentru perioada selectata!",48,"Atentie")
			Thisform.txtDataI.SetFocus()
		ENDIF
	ENDPROC

	PROCEDURE do_excel
		DO export_excel_grid WITH this.grid_web_retetar, 'denumire', "cant_nec > cant_in_stoc" IN proceduri_excel.prg
	ENDPROC

	PROCEDURE do_modifica_nrportii
		Local lnIdArticol, lnCantitate, lnPoz, lnCantePrec, lnCantNecPrec, lnCantNec, lnDif, lnCantStoc, lcCursorTemp
		If Reccount(Thisform.cCrsRetete) >0
			Select (Thisform.cCrsVanzari)
			lnIdArticol = id_articol
			lnCantitate = cant_de_produs
			lcCursorTemp = Sys(2015)
			If lnCantitate <> Thisform.nValoareVeche
				Select (Thisform.cCrsRetete)
				Scan For id_produs = lnIdArticol
					lnPoz = Recno()
					lnIdMaterial = id_material
					lnCantNecReteta = Round(cant_mat * lnCantitate,gnPCant)
					lnCantNec = Round(cant_mat * (lnCantitate - Thisform.nValoareVeche),gnPCant)
					Select (Thisform.grid_web_retetar.RecordSource)
					Locate For id_articol = lnIdMaterial
					If Found()
						lnCantStoc = cant_in_stoc
						lnCantNecPrec = cant_nec
						lnCantNec = cant_nec + lnCantNec
						Select (Thisform.cCrsRetete)
						If lnCantitate > Thisform.nValoareVeche
							If lnCantStoc >= lnCantNec
								Replace cant_nec With lnCantNecReteta,cante With lnCantNecReteta
							Else
								*!*	cantitate pe care mai puteam sa o iau de pe articol
								lnCantE = MAX(0,lnCantStoc - lnCantNecPrec)
								Replace cant_nec With lnCantNecReteta,cante WITH cante + lnCantE
								lnDif = lnCantNec - lnCantNecPrec - lnCantE
								If Used(lcCursorTemp)
									Use In (lcCursorTemp)
								Endif
								Select id_articol,datain From (Thisform.cCrsRetete) ;
									WHERE id_material = lnIdMaterial And Isnull(id_produs) ;
									ORDER By datain ;
									INTO Cursor (lcCursorTemp)
								*!*	adaug diferenta pe articolele secundare
								Select (lcCursorTemp)
								Scan
									lnIdArticolSec = id_articol
									ldDataIn = datain
									Select (Thisform.cCrsRetete)
									Locate For id_articol = lnIdArticolSec And id_material = lnIdMaterial And Isnull(id_produs) ;
										AND cant_in_stoc > cante And datain = ldDataIn
									*!*	pot avea un articol care sa fie si secundar si principal?ca atunci cant_in_stoc nu mai e corecta
									If Found() And lnDif > 0
										Replace cante With Min(cant_in_stoc,cante+lnDif)
										lnDif = lnDif - Min(cant_in_stoc-cante,lnDif)
									Endif
									Select (lcCursorTemp)
								Endscan
								If Used(lcCursorTemp)
									Use In (lcCursorTemp)
								Endif
							Endif
						Else
							If lnCantNecPrec <= lnCantStoc
								Replace cant_nec With lnCantNecReteta,cante With lnCantNecReteta
							Else
								lnCanteDifArticol = Min(cante,lnCantNecReteta) - cante
								Replace cant_nec With lnCantNecReteta,cante With Min(cante,lnCantNecReteta)
								lnDif = lnCantNec - lnCantNecPrec + lnCanteDifArticol
		*!*							If (lnCantNec >= lnCantStoc OR (lnCantNec < lnCantStoc AND )) And lnCanteDifArticol < 0
								*!*	caut dupa id_articol si ii pun cantitatea scazuta de pe reteta asta pe alt articol
								Select (Thisform.cCrsRetete)
								Locate For id_articol = lnIdMaterial And !Inlist(Nvl(id_produs,-1000),-1000,lnIdArticol) ;
									AND cant_nec > cante
								Do While Found() AND lnCanteDifArticol < 0
									Replace cante With Min(cant_nec,Abs(lnCanteDifArticol))
									lnCanteDifArticol = lnCanteDifArticol + Min(cant_nec,Abs(lnCanteDifArticol))
									Continue
								Enddo
		*!*							ELSE
		*!*								lnCanteDifArticol = 0
		*!*							Endif
		*!*						din ce aveam initial de scazut si ce am scazut din articolul principal,
		*!*						 scot ce nu am reusit sa redistribui
								lnDif = lnDif - lnCanteDifArticol
								If Used(lcCursorTemp)
									Use In (lcCursorTemp)
								Endif
								Select id_articol,datain From (Thisform.cCrsRetete) ;
									WHERE id_material = lnIdMaterial And Isnull(id_produs) ;
									ORDER By datain Desc ;
									INTO Cursor (lcCursorTemp)
								*!* scad diferenta de pe articolele secundare
								Select (lcCursorTemp)
								Scan
									lnIdArticolSec = id_articol
									ldDataIn = datain
									Select (Thisform.cCrsRetete)
									Locate For id_articol = lnIdArticolSec And id_material = lnIdMaterial And Isnull(id_produs) ;
										AND datain = ldDataIn And cante <> 0
									If Found() And lnDif < 0
										Replace cante With Max(cante + lnDif,0)
										lnDif = lnDif - Max(lnDif,cante*(-1))
									Endif
									Select (lcCursorTemp)
								Endscan
								If Used(lcCursorTemp)
									Use In (lcCursorTemp)
								Endif
		
							Endif
						Endif
					Endif
					Select (Thisform.cCrsRetete)
					Goto lnPoz
				Endscan
		
				Thisform.actualizeaza_grid2()
			Endif
		Endif
	ENDPROC

	PROCEDURE do_reset
		x = xmenu("Cantitatile pentru produsele \<fara retete;Cantitatile pentru produsele cu \<retete;\<Toate cantitatile de produs")
		Do Case
			Case x = 1
				Select (Thisform.grid_web.RecordSource)
				lnPoz = Recno()
				Replace cant_de_produs With 0 For nuInRetetar = 1
				Goto lnPoz
			Case x = 2
				If aMESSAGEBOX("Sunteti sigur ca doriti sa resetati toate cantitatile pentru produsele cu retete?",4+32,"Atentie")=6
					Select (Thisform.grid_web.RecordSource)
					lnPoz = Recno()
					Replace cant_de_produs With 0 For nuInRetetar = 0
					Goto lnPoz
					Select (Thisform.cCrsRetete)
					Replace cante With 0,cant_nec WITH 0 All
					Thisform.actualizeaza_grid2()
				Endif
			Case x = 3
				If aMESSAGEBOX("Sunteti sigur ca doriti sa resetati toate cantitatile de produs?",4+32,"Atentie")=6
					Select (Thisform.grid_web.RecordSource)
					lnPoz = Recno()
					Replace cant_de_produs With 0 All
					Goto lnPoz
					Select (Thisform.cCrsRetete)
					Replace cante With 0,cant_nec WITH 0 All
					Thisform.actualizeaza_grid2()
				Endif
			Otherwise
				aMESSAGEBOX("Optiune invalida!",16,"Eroare")
		Endcase
	ENDPROC

	PROCEDURE do_termin
		IF this.inainte_de_do_termin()
			gnButon = 1
			pnButon = 1
			Buton = 1
			pnIesire = 1
			*this.Hide 
			SELECT actactan
			llVerificare = verificare_note_contabile('actactan', .T.,.T., .F.)
			If !llVerificare
				This.AlwaysOnTop = .F.
				Do Form verificare With .T.,.T.,3  && cu buton de precedent
				This.AlwaysOnTop = .T.
			Endif
			
			DO CASE 
				CASE gnButon = 3
					*onirbon.visible = .t.
					* DO nrord WITH lcSelRul
				OTHERWISE 
					this.Release 
			ENDCASE 
		ENDIF 
	ENDPROC

	PROCEDURE inainte_de_do_listare
		Thisform.AlwaysOnTop = .F.
		Select * From (Thisform.grid_web_retetar.RecordSource) Where cant_nec > cant_in_stoc Into Cursor cList
		goExport.export2frx([cList],[rap_descarcare_retetar])
		If Used("cList")
			Use In cList
		Endif
		Thisform.AlwaysOnTop = .T.
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local llReturn
		llReturn = .F.
		Do Case
			Case Empty(gcGestPermis)
				AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			Case !Used("cWeb_Vanzari")
				AMESSAGEBOX("Nu exista inregistrari!",0+48,"Atentie")
			Case Empty(pnIdGest_InProd)
				AMESSAGEBOX("Nu ati completat gestiunea in care intra produsele!",0+48,"Atentie")
				Thisform.cbo_idGest_inProd.SetFocus()
			Otherwise
				Select (Thisform.grid_web.RecordSource)
				Locate For cant_de_produs > 0
				If !Found()
					AMESSAGEBOX("Nu ati completat cantitatile!",48,"Atentie")
					Thisform.grid_web.SetFocus()
				Else
					Locate For nuInRetetar = 1 And cant_de_produs > 0
					If Found()
						AMESSAGEBOX("Exista produse care nu au definita fisa tehnologica!",0+48,"Atentie")
						Thisform.grid_web.SetFocus()
					Else
						Select (Thisform.grid_web_retetar.RecordSource)
						Locate For cante > cant_in_stoc
						If Found()
							AMESSAGEBOX("Exista materii prime pentru care cantitatea care se scade depaseste cantitatea din stoc!",0+48,"Atentie")
							Thisform.grid_web_retetar.SetFocus()
						Else
		*!*						Locate For cante > 0
		*!*						If !Found()
		*!*							AMESSAGEBOX("Nu ati completat cantitatile pentru materiale!",48,"Atentie")
		*!*							Thisform.grid_web_retetar.SetFocus()
		*!*						Else
								llReturn = Thisform.completeaza_actactan()
		*!*						Endif
						Endif
					Endif
				Endif
		Endcase
		Return llReturn
		
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Thisform.cCrsVanzari = Alltrim(Thisform.grid_web.RecordSource)
		
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		lcObiect = Upper(Alltrim(This.ActiveControl.Name))
		Do Case
			Case lcObiect = [GRID_WEB] And Between(nKeyCode,48,57) And nShiftAltCtrl = 0
				Thisform.grid_web.cCant_de_produs.SetFocus()
				DoDefault(nKeyCode,nShiftAltCtrl)
			Case lcObiect = [GRID_WEB_RETETAR] And Between(nKeyCode,48,57) And nShiftAltCtrl = 0
				Thisform.grid_web_retetar.cCantE.SetFocus()
				DoDefault(nKeyCode,nShiftAltCtrl)
			Otherwise
				DoDefault(nKeyCode,nShiftAltCtrl)
		Endcase
		
	ENDPROC

	PROCEDURE Show
		Lparameters nStyle
		Local loCauta
		pnIdGest_InMarf = 0
		Do While pnIdGest_InMarf = 0
			loCauta = caut_gestiune(0,gnIdUtil,.F.,[ALEGETI GESTIUNEA IN CARE INTRA MARFURILE])
			If gnButon = 1
				pnIdGest_InMarf = loCauta.id_gestiune
				Thisform.ntipgest = loCauta.nr_pag
				DoDefault(nStyle)
			Else
				Nodefault
				Return .F.
			Endif
		Enddo
		Select crsGestiuni
		Locate For id_gestiune = pnIdGest_InMarf
		If Found()
			pnIdGest_InProd = pnIdGest_InMarf
			Thisform.cbo_idGest_inProd.Value = Alltrim(nume_gestiune)
		Else
			Go Top
		Endif
	ENDPROC

	PROCEDURE cboListe.Valid
		Select (Thisform.grid_web.RecordSource)
		If cListePreturi.id_pol <> -9999
			Set Filter To id_pol = cListePreturi.id_pol
		Else
			Set Filter To
		Endif
		Thisform.grid_web.Refresh()
		
	ENDPROC

	PROCEDURE cbo_idGest_inProd.Valid
		pnIdGest_InProd = crsGestiuni.id_gestiune
		
	ENDPROC

	PROCEDURE ck_cant.Click
		Select (Thisform.grid_web.RecordSource)
		If This.Value = 1
			Set Filter To cant_de_produs <> 0
		Else
			Set Filter To
		Endif
		Thisform.grid_web.Refresh()
		
	ENDPROC

	PROCEDURE grid_web.cCant_de_produs.Text1.GotFocus
		Thisform.nValoareVeche = This.Value
	ENDPROC

	PROCEDURE grid_web.cCant_de_produs.Text1.Valid
		Do Case
			Case This.Value < 0
				Wait Window 'Cantitatea trebuie sa fie nenegativa!' Nowait
				Select (Thisform.grid_web.RecordSource)
				Replace cant_de_produs With Thisform.nValoareVeche
				Thisform.nValoareVeche = 0
			Case Thisform.nValoareVeche <> This.Value
				Thisform.do_modifica_nrportii()
				Thisform.nValoareVeche = 0
			Otherwise
				*!*	nimic
		Endcase
	ENDPROC

	PROCEDURE grid_web.cDenumire.Text1.DblClick
		LOCAL lcTabelProduse, lnId_Produs, lcDenumire_pr  
		STORE '' TO lcTabelProduse, lcDenumire_pr  
		STORE 0 TO lnId_Produs
		
		lcTabelProduse = thisform.grid_web.RecordSource
		SELECT (lcTabelProduse)
		
		lnId_Produs = id_articol
		lcDenumire_pr = ALLTRIM(denumire)
		 
		Private poReteta
		Store '' To poReteta
		
		Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
		*!*	lcSchema1 = [id_ctr N(5), id_part N(10), nume C(30), nr_ctr N(10), data_ctr D(8), obiect C(200), tip N(1), durata N(3), valftva N(20,4), proc_tva N(5,2), avans N(20,4), proc_avans N(5,2),]+;
		*!*		[val_finant N(20,4), proc_finant N(5,2), dobanda N(20,4), proc_dobanda N(5,2), val_rezid N(20,4), proc_rezid N(5,2), ]+;
		*!*		[rata N(20,4), comision N(20,4), proc_comision N(5,2), proc_asigurare N(5,2), val_asigurare N(20,4), val_ctr N(20,4), id_valuta N(5), nume_val C(4), curs N(10,4), zi_plata N(2), incetat N(1), sters N(1) ]
		
		lcSelect1 = [select id_material, denumire_mat, codmat_mat, um_mat, cont_mat, cant_mat from ] + gcS + [.vgest_retetar ]
		lcOrder1 = []
		lcgroup = []
		lcFiltru1 = [id_produs=] + ALLTRIM(STR(lnId_Produs))
		lcFiltruOriginal = []
		llModParam = .T.
		llAfiseaza = .F.
		
		gencursor('poReteta','crsReteta', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		poReteta.ca_baza1.afisare()
		
		SELECT crsReteta
		lofr = CREATEOBJECT("frm_reteta")
		lofr.lb_titlu_alb_b121.caption = "Reteta pentru: " + lcDenumire_pr 
		lofr.show(1)
		
		IF USED("crsReteta")
			USE IN crsReteta
		ENDIF 
		
		RELEASE poReteta
	ENDPROC

	PROCEDURE grid_web.Init
		This.SetAll("DynamicBackColor","IIF(nuInRetetar = 1, RGB(255,0,0), RGB(255,255,255))", "Column")
		This.cCant_de_produs.DynamicBackColor = "IIF(nuInRetetar = 1, RGB(255,0,0),RGB(187,235,255))"
	ENDPROC

	PROCEDURE grid_web_retetar.cCante.Text1.GotFocus
		Thisform.nCantVeche = This.Value
	ENDPROC

	PROCEDURE grid_web_retetar.cCante.Text1.Valid
		If This.Value < 0
			Wait Window 'Cantitatea trebuie sa fie nenegativa!' Nowait
			This.Value = Thisform.nCantVeche
		Else
			Select (Thisform.grid_web_retetar.RecordSource)
			If This.Value > cant_in_stoc
				Wait Window 'Nu puteti depasi cantitatea din stoc!' Nowait
				This.Value = Thisform.nCantVeche
			Else
				Replace cantem With This.Value - canter
			Endif
		Endif
	ENDPROC

	PROCEDURE grid_web_retetar.Init
		This.SetAll("DynamicBackColor","IIF(cant_nec > cant_in_stoc, RGB(255,113,113),IIF(cante > cant_in_stoc, RGB(255,205,155)," + ;
			"IIF(adaugat = 1,RGB(255,255,204), RGB(255,255,255))))", "Column")
		This.cCante.DynamicBackColor = "IIF(cant_nec > cant_in_stoc, RGB(255,113,113),IIF(cante > cant_in_stoc, RGB(255,205,155)," + ;
			"IIF(adaugat = 1,RGB(255,255,204), RGB(187,235,255))))"
	ENDPROC

	PROCEDURE Lb_titlu_alb_b121.Init
		IF TYPE('oxset.nume_set') # 'U'
			this.Caption = PROPER(ALLTRIM(oxset.nume_set))
		ENDIF 
	ENDPROC

	PROCEDURE txtDataF.Valid
		pdDataF = this.value 
	ENDPROC

	PROCEDURE txtDataI.Valid
		pdDataI = this.value 
	ENDPROC

	PROCEDURE _shape1.DblClick
		IF thisform.WindowState = 2
			thisform.WindowState = 0
		ELSE 
			thisform.WindowState = 2 
		ENDIF 
	ENDPROC

ENDDEFINE

DEFINE CLASS webnir 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="_shapeSus" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboListe" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column6.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column7.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column7.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column8.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column8.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column11.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column11.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_factura1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataI" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: aleg_cont_transfer
		*m: assign_analitic
		*m: assign_values
		*m: calcul_pret_vanzare
		*m: calcul_sume
		*m: caut_gestiune
		*m: compensare
		*m: do_alege_lista_preturi
		*m: make_rultemp
		*p: cfrm_ceredate
		*p: cobj
		*p: ctip_frm
		*p: ntotal
		*p: osel_dr
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton3 = 
		cbuton4 = Ct_grid_order1.But_sterge1;but_reface1
		cfrm_ceredate = 
		cobj = 
		ctip_frm = NIR
		DoCreate = .T.
		Height = 572
		lactiv1 = .T.
		lactiv3 = .T.
		lactiv4 = .T.
		Name = "webnir"
		ntotal = 0
		osel_dr = 
		Width = 793
		WindowType = 1
		_shape1.Anchor = 11
		_shape1.Height = 30
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Tag = ""
		_shape1.Top = -1
		_shape1.Width = 726
		_shape1.ZOrderSet = 0
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 724
		_shape2.Name = "_shape2"
		_shape2.Tag = "MOVABLE"
		_shape2.Top = 0
		_shape2.Width = 69
		_shape2.ZOrderSet = 1
		Lb_titlu_alb_b121.Anchor = 3
		Lb_titlu_alb_b121.FontName = "Comic Sans MS"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Height = 20
		Lb_titlu_alb_b121.Left = 10
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 8
		Lb_titlu_alb_b121.Top = 3
		Lb_titlu_alb_b121.Width = 41
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 757
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 6
		BUT_TERMIN1.Tag = ""
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 32
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_shapeSus' AS _shape WITH ;
		Anchor = 11, ;
		BackStyle = 0, ;
		BorderColor = 7,118,177, ;
		BorderWidth = 2, ;
		Height = 103, ;
		Left = 8, ;
		Name = "_shapeSus", ;
		Tag = "RESIZABLE, MOVABLE", ;
		Top = 35, ;
		Width = 780, ;
		ZOrderSet = 4
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="shape" />

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

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

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 9, ;
		Left = 727, ;
		Name = "But_renunt1", ;
		TabIndex = 7, ;
		Tag = "", ;
		Top = 1, ;
		ZOrderSet = 5
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cboListe' AS combobox WITH ;
		Anchor = 3, ;
		ColumnCount = 4, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,65,60,0", ;
		Format = "", ;
		Height = 24, ;
		Left = 65, ;
		Name = "cboListe", ;
		RowSource = "cListePret.nume_lista_preturi,datai,datas,id_pol", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 1, ;
		Top = 147, ;
		Width = 315, ;
		ZOrderSet = 11
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 3, ;
		Left = 295, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 4, ;
		Top = 172
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_factura1' AS ct_factura WITH ;
		Anchor = 131, ;
		Left = 14, ;
		Name = "Ct_factura1", ;
		TabIndex = 9, ;
		Tag = "", ;
		Top = 52, ;
		ZOrderSet = 13, ;
		lbBaza.Name = "lbBaza", ;
		lbTva.Name = "lbTva", ;
		txBaza.Name = "txBaza", ;
		txTva.Name = "txTva", ;
		lbExplic.Name = "lbExplic", ;
		txTotal.Name = "txTotal", ;
		lbTotal.Name = "lbTotal"
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'grid_web' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 9, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 348, ;
		HighlightStyle = 2, ;
		Left = 8, ;
		Name = "grid_web", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "cWeb_vanzari", ;
		TabIndex = 5, ;
		Top = 206, ;
		Width = 778, ;
		ZOrderSet = 20, ;
		Column1.ControlSource = "nr_crt", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Format = "rk", ;
		Column1.InputMask = "9999", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 26, ;
		Column2.ControlSource = "codmat", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 44, ;
		Column3.ControlSource = "denumire", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 216, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "cant_vand", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(7,gnPCant)), ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 48, ;
		Column5.ColumnOrder = 4, ;
		Column5.ControlSource = "pretvtva", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPPretV)), ;
		Column5.Name = "Column5", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 71, ;
		Column6.ControlSource = "cant_in_stoc", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.Format = "rk", ;
		Column6.InputMask = (get_mask(7,gnPCant)), ;
		Column6.Name = "Column6", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 52, ;
		Column7.BackColor = 223,248,255, ;
		Column7.ControlSource = "cante", ;
		Column7.DynamicBackColor = "223,248,255", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.Format = "rk", ;
		Column7.InputMask = (get_mask(7,gnPCant)), ;
		Column7.Name = "Column7", ;
		Column7.ReadOnly = .F., ;
		Column7.Width = 53, ;
		Column8.ColumnOrder = 9, ;
		Column8.ControlSource = "val_vand", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.Format = "rk", ;
		Column8.InputMask = (get_mask(7,gnPC)), ;
		Column8.Name = "Column8", ;
		Column8.ReadOnly = .F., ;
		Column8.Width = 94, ;
		Column9.ColumnOrder = 8, ;
		Column9.ControlSource = "cant_ramasa_de_scazut", ;
		Column9.FontName = "Arial Narrow", ;
		Column9.Format = "rk", ;
		Column9.InputMask = (get_mask(7,gnPCant)), ;
		Column9.Name = "Column11", ;
		Column9.ReadOnly = .F.
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. crt.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column11.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate ramasa de scazut", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column11.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod mat.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate vanduta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret de vanzare (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column7.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate ce se scade", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column7.Text1' AS textbox WITH ;
		BackColor = 223,248,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.Column8.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare vanduta ce se scade (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column8.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada", ;
		Height = 17, ;
		Left = 8, ;
		Name = "Label1", ;
		TabIndex = 10, ;
		Top = 177, ;
		Width = 52, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "-", ;
		Height = 17, ;
		Left = 176, ;
		Name = "Label2", ;
		TabIndex = 11, ;
		Top = 177, ;
		Width = 6, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Lista de preturi", ;
		Height = 32, ;
		Left = 8, ;
		Name = "Label3", ;
		TabIndex = 12, ;
		Top = 143, ;
		Width = 46, ;
		WordWrap = .T., ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDataF' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataF", ;
		Format = "k", ;
		Height = 23, ;
		Left = 184, ;
		Name = "txtDataF", ;
		TabIndex = 3, ;
		Top = 174, ;
		Width = 109, ;
		ZOrderSet = 18
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtDataI' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataI", ;
		Format = "k", ;
		Height = 23, ;
		Left = 65, ;
		Name = "txtDataI", ;
		TabIndex = 2, ;
		Top = 174, ;
		Width = 109, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Activate
		this.WindowState = 2
	ENDPROC

	PROCEDURE aleg_cont_transfer
		PARAMETERS tnIdGest
		lcSql = [select (case when p.explicatie is null then s.explicatie else p.explicatie end) as explicatie,] +;
				[c.cont, p.acont from VCORESP_CONT_TIPGEST c ] +; 
				[left join vplcont_analitic p on c.cont = p.cont and p.an = ?gnAn ] +;
				[left join vplcont_sintetic s on c.cont = s.cont and s.an = ?gnAn ]
		pcFiltruOrig = [c.id_tipgest in (select nr_pag from vnom_gestiuni where id_gestiune = ?tnIdGest)] 
		pcfiltru = [1=2]
		pcschema = ['']
		pcorder = [cont,acont]
		pccoloane = [cont,acont,explicatie]
		pcTitlu = [Alegeti Contul de Transfer] 
		pcTitluColoane = [Cont,Analitic,Explicatie cont]
		locauta = cauta_alfa(lcSql,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,'',.F.,pcFiltruOrig)		&& 11.07.2007
			
		RETURN loCauta
	ENDPROC

	PROCEDURE assign_analitic
		PARAMETERS tcCont,pcAct,pcRul
		
		PRIVATE pcCont,pcAct,pcRul,pParamP,pParamS
		STORE 0 TO pParamP,pParamS
		lcAnalitic = ''
		lcAlias = ALIAS()
		
		pcCont = ALLTRIM(tcCont)
		
		lcSel = [SELECT * from ] + gcs + [.config_analitice WHERE cont = ?pcCont]
		lcCursor = 'crs_cfg_ana'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		IF lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_cfg_ana')=0
				USE IN crs_cfg_ana
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			SELECT crs_cfg_ana
			SCATTER NAME ocfg
			lcCampPrefix = NVL(ALLTRIM(ocfg.camp_leg_prefix),'')
			lcCampSufix = NVL(ALLTRIM(ocfg.camp_leg_sufix),'')
			
			IF !EMPTY(lcCampPrefix)
				IF TYPE('&pcRul..'+lcCampPrefix) # 'U'
					pParamP = &pcRul..&lcCampPrefix
				ELSE 
					IF TYPE('&pcAct..'+lcCampPrefix) # 'U'
						pParamP = &pcAct..&lcCampPrefix
					ENDIF 
				ENDIF 
			ENDIF 
			
			IF !EMPTY(lcCampSufix)
				IF TYPE('&pcRul..'+lcCampSufix) # 'U'
					pParamS = &pcRul..&lcCampSufix 
				ELSE 
					IF TYPE('&pcAct..'+lcCampSufix) # 'U'
						pParamS = &pcAct..&lcCampSufix 
					ENDIF 
				ENDIF 
			ENDIF 
		
			lcSel = [{call fconturi_analitice(?gcs,?pcCont,0,?pParamP,?pParamS)}]
			lcCursor = 'crs_analitice'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		&& iau Primul Simbol Analitic din Tabel - ordonat pt ca e selectat cu Distinct
		IF lnSucces > 0
			SELECT crs_analitice
			GO top
			lcAnalitic = ALLTRIM(acont)
		ENDIF 
		
		&& verificare analiticului cu Planul de Conturi
		IF lnSucces > 0
			lcSel = [SELECT cont,acont from ] + gcs + [.vplcont_analitic WHERE cont = ?pcCont and acont = ?lcAnalitic and an = ?gnAn ]
			lcCursor = 'crs_verific'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_verific')=0
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF USED('crs_cfg_ana')
			USE IN crs_cfg_ana
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		IF USED('crs_analitice')
			USE IN crs_analitice
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		
		IF lnSucces < 0
			lcAnalitic = ''
		ENDIF 
		
		SELECT (lcAlias)
		RETURN lcAnalitic
		
	ENDPROC

	PROCEDURE assign_values
		PARAMETERS tcObjDestinatie, tcObjSursa1, tcObjSursa2
		
		* lcSelRul = this.ct_grid_order1.cnumecursor 
		
		lcOdest = ALLTRIM(tcObjDestinatie)
		lcOsursa1 = ALLTRIM(tcObjSursa1)
		lcOsursa2 = ALLTRIM(tcObjSursa2)
		
		*!*	SELECT (lcSelRul)
		*!*	FOR i = 1 TO FCOUNT()
		*!*		lcNumeCol = FIELD(i)
		*!*		IF TYPE('&lcOsursa1..'+lcNumeCol) # 'U'
		*!*			&lcodest..&lcNumeCol = &lcosursa1..&lcNumeCol
		*!*		ENDIF 
		*!*		IF TYPE('&lcOsursa2..'+lcNumeCol) # 'U'
		*!*			IF EMPTY(&lcodest..&lcNumeCol)
		*!*				&lcodest..&lcNumeCol = &lcosursa2..&lcNumeCol
		*!*			ENDIF 
		*!*		ENDIF 
		*!*	ENDFOR 
		
		
		
		
		
		 
	ENDPROC

	PROCEDURE calcul_pret_vanzare
		PARAMETERS tcTabel
		
		LOCAL lnPretv, lnTvav, lnCoefAdaos, lnSuma, lcTabel
		STORE 0 TO lnPretv, lnTvav, lnCoefAdaos, lnSuma
		
		IF EMPTY(tcTabel)
			lcTabel = this.ct_grid_order1.cnumecursor 
		ELSE 
			lcTabel = ALLTRIM(tcTabel)
		ENDIF 
		
		SELECT (lcTabel)
		SUM ROUND(ABS(cante*pret),gnPc) TO lnSuma
		
		IF lnSuma <> 0
			lnCoefAdaos = (pcobj.totftva-lnSuma)/lnSuma  && coeficientul mediu de adaos
		ELSE 
			lnCoefAdaos = 1
		ENDIF 
		
		SELECT (lcTabel)
		SET FILTER TO 
		REPLACE ALL proc_tvav WITH pcobj.proc_tva, procent WITH ROUND(lnCoefAdaos*100,2)
		CALCULATE cnt() TO lnRecords
		i = 0
		SCAN 
			i = i + 1
			REPLACE pretv WITH pret + ROUND(pret*lnCoefAdaos,gnPpret) 
			REPLACE tvav WITH ROUND(pretv*(proc_tvav-1),gnPpret)
			lnPretv = lnPretv + ROUND(pretv*cante,gnPC)
			lnTvav = lnTvav + ROUND(tvav*cante,gnPC)
			IF i = lnRecords
				IF lnPretv # pcobj.totftva 
					REPLACE pretv WITH pretv + ROUND((pcobj.totftva - lnPretv)/cante,gnPpret)
				ENDIF 
				IF lnTvav # pcobj.tottva
					REPLACE tvav WITH tvav + ROUND((pcobj.tottva - lnTvav)/cante,gnPpret)
				ENDIF 
			ENDIF 
		ENDSCAN 
		
	ENDPROC

	PROCEDURE calcul_sume
		PARAMETERS tcTabel
		STORE 0 TO lnTotBaza, lnTotTva, lnBazaDiscount, lnBazaAdaos, lnTvaDiscount, lnTvaAdaos
		
		lcCant = this.osel_dr.cantitate
		IF PCOUNT() = 0
			tcTabel =  ALLTRIM(THIS.ct_grid_order1.cnumecursor)
		ENDIF
		
		SELECT (tcTabel)
		SUM ROUND(&lcCant*PRET,gnPc) TO THISFORM.ntotal
		lnTotBaza = THISFORM.ntotal
		
		WAIT WINDOW ALLTRIM(STR(lnTotBaza))  
		
		SUM ROUND(ROUND(&lcCant*PRET,gnPc) * (proc_tva-1),gnPc) TO lnTotTva
		
		THIS.txNir.REFRESH
		THIS.ct_factura1.REFRESH
		THIS.ct_adaos1.REFRESH
		
	ENDPROC

	PROCEDURE caut_gestiune
		PARAMETERS tnFel
		
		IF EMPTY(tnFel)
			tnFel = 0
		ENDIF 
		
		IF tnFel = 1 && pret vanzare
			lcCond = [nr_pag = 6]
		ELSE 
			lcCond = [nr_pag in (2,3,4,5)]
		ENDIF 
		
		pcselect = [select * from vnom_GESTIUNI]
		pcFiltruOrig = [inactiv = 0 and ] + lcCond
		pcfiltru = [1=2]
		pcschema = []
		pcorder = [NUME_gestiune]
		pccoloane = [nume_gestiune,cgest]
		pcTitlu = [Nume Gestiune Destinatie] 
		pcTitluColoane = [Gestiune,Indicativ]
		locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,'',.F.,pcFiltruOrig)		&& 11.07.2007
			
		RETURN locauta
	ENDPROC

	PROCEDURE compensare
		IF USED('xcont')
			SELECT xcont
			LOCATE FOR Pozitie # Fel_Cont AND Cu_Inregistrari = 1
			IF FOUND()
				pcContul = ALLTRIM(cont_part)
				pnIdPart = idPart
				pcNume = numepart
				pnFelCont = Fel_Cont
				pcDenumire = ALLTRIM(explic_cont)
		
				pcCond = [ an = ?gnAn and luna = ?gnluna]
		
				llval = .F. && Deocamdata e doar in lei
				IF llval
					pccond= pccond + [ and ABS(i.precvaldeb + i.valdebit - i.precvalcred - i.valcredit)>0 and i.id_valuta = ] + ALLTRIM(STR(&lcObj..id_valuta))
				ELSE
					pccond= pccond + [ and (i.precvaldeb + i.valdebit - i.precvalcred - i.valcredit = 0) ]
				ENDIF
		
		
		
				pcselect = ['select i.* FROM ] + gcs + [.Vireg_parteneri i where 2=2 ']
				pcfiltru = [ i.id_part = ?pnIdPart AND ABS(i.precdeb + i.debit - i.preccred - i.credit)<>0 AND i.cont = ?pcContul and ] + pcCond
				pcschema = ['']
				pcorder = ['']
		
				PRIVATE podateintrod
				STORE '' TO podateintrod
		
				gencursor('podateintrod','crs_actcv',pcselect,pcfiltru,[''],'')
		
				lcFis = 'actcv' + ALLTRIM(pcContul)
		
				IF USED(lcFis)
					USE IN &lcFis
				ENDIF
		
				IF pnFelCont = 0
					lcsel = [SELECT *, ACONT AS ASCC, nume_val as numeval, curs as cursschimb, precdeb + debit as totctva, preccred+credit as achitat, ] +;
						[precvaldeb + valdebit AS sumaval, precVALcred+VALcredit as achitatval, ] +;
						[.f. as ales, 00000000000000.0000 as sumaachi, 000000000000.0000 as sumaachi2, 00000000000000.0000 as achilei, 00000000000000.0000 as difplus, 00000000000000.0000 as difminus, 000000.0000 as cursval, 000000.0000 as cursdif ] +;
						[FROM crs_actcv INTO CURSOR ] + lcFis + [ READWRITE ]
				ELSE
					lcsel = [SELECT *, ACONT AS ASCD, nume_val as numeval, curs as cursschimb, preccred + credit as totctva, precdeb+debit as achitat, ] + ;
						[precvalcred + valcredit as sumaval, precVALdeb+VALdebit as achitatval, ] + ;
						[.f. as ales, 00000000000000.0000 as sumaachi, 00000000000000.0000 as sumaachi2, 00000000000000.0000 as achilei, 00000000000000.0000 as difplus, 00000000000000.0000 as difminus, 000000.0000 as cursval, 000000.0000 as cursdif ] + ;
						[FROM crs_actcv INTO CURSOR ] + lcFis + [ READWRITE ]
				ENDIF
				&lcsel
		
				SELECT (lcFis)
		
				OPLATA=CREATEOBJECT('ocompensari')
				*		oplata.txtNume.value =lcNume
				OPLATA.titlufrumos1.CAPTION = pcDenumire + [: ] + pcNume
				OPLATA.pcFis = lcFis
				OPLATA.SUMA = THIS.ct_factura1.totctva
				OPLATA.pnFelCont = pnFelCont
				OPLATA.SHOW(1)
		
				*!*			SELECT (lcfis)
				*!*			CALCULATE cnt() FOR ales TO LnBife
				*!*			IF LnBife=1
				*!*				LOCATE FOR ALES
				*!*				&M=nract
				*!*			ELSE
				*!*				&M=0
				*!*			ENDIF
			ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE do_adauga
		*!*	PRIVATE pnpretvtva
		*!*	pnpretvtva = 0
		*!*	lcNomArt = this.ct_grid_search1.cnumecursor 
		*!*	SELECT (lcNomArt)
		*!*	SCATTER NAME lorec blank	
		
		*!*	PRIVATE poCote_tva
		*!*	STORE '' TO poCote_tva	
		
		*!*	DO Adauga_Modifica_Inregistrare WITH [catalog_articole],lorec,,[INSERT]
		*!*	this.ct_grid_search1.actualizeaza_grid
	ENDPROC

	PROCEDURE do_alege_lista_preturi
		LOCAL lnTotctva, lnTotftva, lnTva 
		STORE 0 TO lnTotctva, lnTotftva, lnTva 
		
		IF EMPTY(gcGestPermis)
			AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			RETURN
		ENDIF 
		
		IF EMPTY(pnId_lista)
			AMESSAGEBOX("Alegeti o lista de preturi!",0+48,"Atentie")
			RETURN
		ENDIF 
		IF EMPTY(pdDataI)
			AMESSAGEBOX("Completati data initiala !",0+48,"Atentie")
			RETURN
		ENDIF 
		IF EMPTY(pdDataF)
			AMESSAGEBOX("Completati data finala !",0+48,"Atentie")
			RETURN
		ENDIF 
		
		pcPerioada = DTOC(pdDataI) + " - " + DTOC(pdDataF)
		
		save_grid_tag(thisform.grid_web)
		
		*!* lcSel = [{call pack_gest_vanzari.vanzari_stoc(?pnId_lista, ?pdDataI, ?pdDataF, ?gnAn, ?gnLuna, ?pnNr_pag, ?gcGestPermis)}]
		lcSel = [{call pack_gest_vanzari.vanzari_stoc(] + TRANSFORM(pnId_lista) + ;
			[,TO_DATE('] +  TTOC(pdDataI,1) + [','YYYYMMDDHH24:MI:SS'), TO_DATE('] + TTOC(pdDataF,1)  + [','YYYYMMDDHH24:MI:SS'),] + ;
			TRANSFORM(gnAn) + [,] + TRANSFORM(gnLuna) + [,] + TRANSFORM(gnTipGest) + [,'] +  ;
			ALLTRIM(TRANSFORM(poAct.id_gestiune)) + [',?gnIdSucursala)}]
		lcCursor = 'cweb_vanzari'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		
		IF lnSucces < 0
			amessage('Call pack_gest_vanzari.vanzari_stoc' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
			RETURN
		ENDIF
		
		restore_grid_tag(thisform.grid_web)
		* thisform.grid_web.Refresh 
		
		SELECT cweb_vanzari
		*!*	modificare	07.11.2012	:	am pus gnPC in loc de gnPa la lnTotftva
		CALCULATE SUM(ROUND(pretvtva*cante,gnPC)), SUM(ROUND(pretvtva/proc_tvav*cante,gnPC)) TO lnTotctva, lnTotftva
		lnTva = lnTotctva - lnTotftva
		GO TOP 
		
		thisform.ct_factura1.txTotal.Value = lnTotctva
		thisform.ct_factura1.txBaza.Value = lnTotftva
		thisform.ct_factura1.txTva.Value = lnTva 
		
		thisform.Refresh 
		
		
		
		
		
	ENDPROC

	PROCEDURE do_cauta
		thisform.do_alege_lista_preturi()
	ENDPROC

	PROCEDURE do_excel
		DO export_excel_grid WITH this.grid_web, 'denumire' IN proceduri_excel.prg
	ENDPROC

	PROCEDURE do_modifica
		*!*	lcNomArt = this.ct_grid_search1.cnumecursor 
		*!*	SELECT (lcNomArt)
		*!*	SCATTER NAME lorec 	
		
		*!*	PRIVATE poCote_tva
		*!*	STORE '' TO poCote_tva
		*!*		
		*!*	lnId = lorec.id_articol	
		*!*	DO Adauga_Modifica_Inregistrare WITH [catalog_articole],lorec,lnId,[UPDATE]
		*!*	this.ct_grid_search1.actualizeaza_grid
	ENDPROC

	PROCEDURE do_sterge
		LOCAL lnRecno, lcSelRul
		* lcSelRul = this.ct_grid_order1.cnumecursor 
		
		SELECT (lcSelRul)
		*SCATTER NAME osterg
		lnRecno = RECNO()
		DELETE 
		
		*!* MODIFICAT 11.04.2006
		*!* MARIUS.MUTU - AM PUS RECNO('RUL_TEMP') IN CURSORUL DE TRANSFER - LA STERGERE SA POT STERGE SI LINIA CORESPONDENTA DIN CRSTRANSFER	
		
		*!*	IF INLIST(oset.model,5,6) AND USED('crsTransfer')	
		*!*		SELECT crsTransfer
		*!*		GOTO lnRecno
		*!*		DELETE 
		*!*		this.ct_grid_order1.cb_tx_gestin.SetFocus()
		*!*	ENDIF 
		
		*!*	this.ct_grid_order1.actualizeaza_grid 
		*!*	this.calcul_sume
		
		
	ENDPROC

	PROCEDURE do_termin
		IF this.inainte_de_do_termin()
			gnButon = 1
			pnButon = 1
			Buton = 1
			pnIesire = 1
			*this.Hide 
			SELECT actactan
			*!*	modificare ROAGRESTAURANT v 0.0.14
			llVerificare = verificare_note_contabile('actactan', .T.,.T., .F.)
			If !llVerificare
			*!*	modificare ROAGRESTAURANT v 0.0.14	^
				This.AlwaysOnTop = .F.
				Do Form verificare With .T.,.T.,3  && cu buton de precedent
				This.AlwaysOnTop = .T.
			Endif
			
			DO CASE 
				CASE gnButon = 3
					*onirbon.visible = .t.
					* DO nrord WITH lcSelRul
				OTHERWISE 
					this.Release 
			ENDCASE 
		ENDIF 
	ENDPROC

	PROCEDURE inainte_de_do_listare
		thisform.AlwaysOnTop = .F.
		
		
		LOCAL lcTabel
		lcTabel = THISFORM.grid_web.RECORDSOURCE
		SELECT (lcTabel)
		
		lcmenu = "\<Articole cu stoc insuficient;\<Toate articolele"
		lnx = xmenu(lcmenu)
		DO CASE
			CASE lnx = 1
				SELECT * FROM (lcTabel) WHERE cant_vand > cant_in_stoc INTO CURSOR cList
				SELECT cList
				REPORT FORM rap_descarcare TO PRINTER PROMPT PREVIEW
				IF USED("cList")
					USE IN cList
				ENDIF
			CASE lnx = 2
				SELECT (lcTabel)
				REPORT FORM rap_descarcare TO PRINTER PROMPT PREVIEW
		ENDCASE
		
		thisform.AlwaysOnTop = .T.
	ENDPROC

	PROCEDURE inainte_de_do_termin
		LOCAL lcSelRul, lcContTr, lcAcontTr, lcRul, lcSql, lcCursor, lnSucces, lcCant
		STORE '' TO lcContTr, lcAcontTr
		
		LOCAL lnRecno
		lnRecno = 0
		
		IF EMPTY(gcGestPermis)
			AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			RETURN .F.
		ENDIF
		
		IF !USED("cWeb_Vanzari")
			AMESSAGEBOX("Tabelul de vanzari nu contine inregistrari!",0+48,"Atentie")
			RETURN .F.
		ENDIF
		
		*** completez tabela ACTACTAN
		IF TYPE('oitem') = 'O'
			IF PEMSTATUS(oitem,'adunadate',5)
				oitem.adunadate()
			ENDIF
		ENDIF
		
		llSucces = THIS.MAKE_RULTEMP()
		IF !llSucces
			RETURN .F.
		ENDIF
		***********************************************************************************************************************8
		SELECT rul_temp && crsStocTemp
		CALCULATE SUM(ROUND(PRET*cante,gnPc)), SUM(ROUND(pretv*cante - PRET*cante,gnPc)) TO pnBazaBon, pnAdaos
		pnTvaVanzOut = 0
		
		SELECT cWeb_Vanzari
		* folosesc sumele pentru incasare
		CALCULATE SUM(ROUND(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1),gnPpret)*cant_vand,gnPc)) TO pnBazaFactura
		CALCULATE SUM(ROUND((pretvtva - (pretvtva/IIF(proc_tvav<>0,proc_tvav,1))) * cant_vand,gnPc)) TO pnTVAFactura
		
		***------------------
		* 411 = 70x
		SELECT proc_tvav, SUM(ROUND(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1),gnPPretV)*cant_vand,gnPc)) AS bazaFact ;
			FROM cWeb_Vanzari ;
			GROUP BY proc_tvav ;
			INTO CURSOR cBazaCote
		
		SELECT actactan
		LOCATE FOR LEFT(scd,3) = '411' AND LEFT(scc,1) = '7'
		IF FOUND()
			SCATTER NAME loActBaza
			DELETE
		
			SELECT cBazaCote
			SCAN
				lnProc_tvav = proc_tvav
				lnBazaFact = bazaFact
				SELECT actactan
				loActBaza.proc_tva = lnProc_tvav
				loActBaza.suma = lnBazaFact
				* REPLACE suma WITH pnBazaFactura
				APPEND BLANK
				GATHER NAME loActBaza
				SELECT cBazaCote
			ENDSCAN
		
			IF USED("cBazaCote")
				USE IN cBazaCote
			ENDIF
			RELEASE loActBaza
		
		ENDIF
		
		
		
		***------------------
		* 411 = 4427
		SELECT proc_tvav, SUM(ROUND((pretvtva - (pretvtva/IIF(proc_tvav<>0,proc_tvav,1))) * cant_vand,gnPc)) AS TVAFact ;
			FROM cWeb_Vanzari ;
			GROUP BY proc_tvav ;
			INTO CURSOR cTVACote
		
		SELECT actactan
		LOCATE FOR LEFT(scd,3) = '411' AND ALLTRIM(scc) = '4427'
		IF FOUND()
			SCATTER NAME loActTVA
			DELETE
		
			SELECT cTVACote
			SCAN
				lnProc_tvav = proc_tvav
				lnTVAFact = TVAFact
				SELECT actactan
				loActTVA.proc_tva = lnProc_tvav
				loActTVA.suma = lnTVAFact
		
				APPEND BLANK
				GATHER NAME loActTVA
				SELECT cTVACote
			ENDSCAN
		
			IF USED("cTVACote")
				USE IN cTVACote
			ENDIF
			RELEASE loActTVA
		
		ENDIF
		
		
		***------------------
		
		*!*	SELECT actactan
		*!*	LOCATE FOR LEFT(scd,3) = '411' AND LEFT(scc,1) = '7'
		*!*	IF FOUND()
		*!*		REPLACE suma WITH pnBazaFactura
		*!*	ENDIF
		
		*!*	SELECT actactan
		*!*	LOCATE FOR LEFT(scd,3) = '411' AND ALLTRIM(scc) = '4427'
		*!*	IF FOUND()
		*!*		REPLACE suma WITH pnTVAFactura
		*!*	ENDIF
		
		SELECT actactan
		LOCATE FOR LEFT(scd,1) = '5' AND LEFT(scc,3) = '411'
		IF FOUND()
			REPLACE suma WITH ROUND(pnBazaFactura + pnTVAFactura,gnPc)
		ENDIF
		
		&& NOTE
		SELECT * FROM XNOTE WHERE id_set = oset.id_set INTO CURSOR crsNota
		
		lcField = ''
		SELECT xact
		GO TOP
		
		FOR i = 1 TO FCOUNT()
			IF UPPER(ALLTRIM(EVALUATE(FIELD(i)))) = 'SUMA'
				lcField = FIELD(i)
				EXIT
			ENDIF
		ENDFOR
		
		IF EMPTY(lcField)
			RETURN .T.
		ENDIF
		
		
		SELECT DISTINCT xscd AS scd, xscc AS scc, PADR(&lcField,100,' ') AS eticheta FROM crsNota ;
			WHERE INLIST(UPPER(ALLTRIM(xscd)),'X') OR INLIST(UPPER(ALLTRIM(xscc)),'X');
			INTO CURSOR crsIcsi
		
		IF _TALLY > 0
		
			SELECT crsIcsi
			SCAN
				lcEticheta = LOWER(ALLTRIM(eticheta))
				IF EMPTY(lcEticheta)
					aMESSAGEBOX('NECONFIGURAT xnote.dbf !',48,'Atentie!')
					LOOP
				ENDIF
				lcSCD = UPPER(ALLTRIM(scd))
				lcSCC = UPPER(ALLTRIM(scc))
				IF INLIST(oset.model, 5, 6) && TRANSFER, RETUR TRANSFER
					IF lcSCD = 'Y'
						lcSCD = lcContTr
					ENDIF
					IF lcSCC = 'Y'
						lcSCC = lcContTr
					ENDIF
				ENDIF
		
				************************************************************************************************************88
				DO CASE
					CASE 'pnadaos' $ lcEticheta
						lcSelect = [SELECT CONT,ACONT,id_gestiune,] + ;
							IIF(TYPE('rul_temp.proc_tvav')#'U',[proc_tvav],[0000]) + [ as proc_tva,] +;
							IIF(TYPE('rul_temp.id_gestin')#'U',[id_gestin],[000000000]) + [ as id_gestin,] + ;
							IIF(TYPE('rul_temp.id_gestout')#'U',[id_gestout],[000000000]) + [ as id_gestout,] + ;
							IIF(TYPE('rul_temp.gestin')#'U',[gestin],[SPACE(50)]) + [ as gestin,] + ;
							IIF(TYPE('rul_temp.gestout')#'U',[gestout],[SPACE(50)]) + [ as gestout,] + ;
							[SUM(ROUND(cante *(pretv-pret),gnPc)) AS suma ] + ;
							[FROM rul_temp where nuInConturiX = 0 into cursor crsConturiX ] + ;
							[GROUP BY 1,2,3,4,5,6,7,8]
						&lcSelect
					CASE 'pntvavanzout' $ lcEticheta
						lcSelect = [SELECT CONT,ACONT,id_gestiune,] + ;
							IIF(TYPE('rul_temp.proc_tva')#'U',[proc_tva],[0000]) + [ as proc_tva,] +;
							IIF(TYPE('rul_temp.id_gestin')#'U',[id_gestin],[000000000]) + [ as id_gestin,] + ;
							IIF(TYPE('rul_temp.id_gestout')#'U',[id_gestout],[000000000]) + [ as id_gestout,] + ;
							IIF(TYPE('rul_temp.gestin')#'U',[gestin],[SPACE(50)]) + [ as gestin,] + ;
							IIF(TYPE('rul_temp.gestout')#'U',[gestout],[SPACE(50)]) + [ as gestout,] + ;
							[SUM(ROUND(cante*ROUND(pretvtva*(proc_tvav-1)/proc_tvav,gnPPretV),gnPC)) AS suma ] + ;
							[FROM rul_temp where nuInConturiX = 0 into cursor crsConturiX ] + ;
							[GROUP BY 1,2,3,4,5,6,7,8]
		
						&lcSelect
		
					OTHERWISE  && pnBazaBon
						lcEticheta =  &lcEticheta
						lcSelect = [SELECT CONT,ACONT,id_gestiune,] + ;
							IIF(TYPE('rul_temp.proc_tva')#'U',[proc_tva],[0000]) + [ as proc_tva,] +;
							IIF(TYPE('rul_temp.id_gestin')#'U',[id_gestin],[000000000]) + [ as id_gestin,] + ;
							IIF(TYPE('rul_temp.id_gestout')#'U',[id_gestout],[000000000]) + [ as id_gestout,] + ;
							IIF(TYPE('rul_temp.gestin')#'U',[gestin],[SPACE(50)]) + [ as gestin,] + ;
							IIF(TYPE('rul_temp.gestout')#'U',[gestout],[SPACE(50)]) + [ as gestout,] + ;
							[SUM(ROUND(cante*pret,gnPC)) AS suma ] + ;
							[FROM rul_temp where nuInConturiX = 0 into cursor crsConturiX ] + ;
							[GROUP BY 1,2,3,4,5,6,7,8]
						&lcSelect
				ENDCASE
		
		
				SELECT crsConturiX
				SCAN FOR suma*0 = 0 && sa evit cazurile in care suma este ******
					SCATTER NAME loCX
					SELECT actactan
					LOCATE FOR UPPER(ALLTRIM(scd)) = lcSCD AND UPPER(ALLTRIM(scc)) = lcSCC
					IF FOUND()
						SCATTER NAME loActactan
						WITH loActactan
							IF UPPER(ALLTRIM(.scd)) = 'X'
								.scd = loCX.CONT
								.ascd = NVL(loCX.acont,'')
								.suma = loCX.suma
								*.proc_tva = loCX.proc_tva
								.id_gestin = loCX.id_gestin
								.gestin = loCX.gestin
								.id_gestout = loCX.id_gestout
								.gestout = loCX.gestout
								*!*							.id_sectie = loCX.id_sectie
								*!*							.sectie = loCX.sectie
							ENDIF
							IF UPPER(ALLTRIM(.scc)) = 'X'
								.scc = loCX.CONT
								.ascc = NVL(loCX.acont,'')
								.suma = loCX.suma
								IF LEFT(.scd,1) = '6' AND ALLTRIM(.scd) # '607' AND INLIST(oset.model, 3, 4) && BON, RETUR
									.scd = STRTRAN(.scc, '3', '6', 1, 1)
								ENDIF
								.proc_tva = loCX.proc_tva
								.id_gestin = loCX.id_gestin
								.gestin = loCX.gestin
								.id_gestout = loCX.id_gestout
								.gestout = loCX.gestout
								*!*							.id_sectie = loCX.id_sectie
								*!*							.sectie = loCX.sectie
							ENDIF
						ENDWITH
						APPEND BLANK
						GATHER NAME loActactan
					ENDIF && IF FOUND()
		
					SELECT crsConturiX
				ENDSCAN
				SELECT crsIcsi
			ENDSCAN
		
			DELETE FROM actactan WHERE INLIST(UPPER(ALLTRIM(scd)),'X') OR INLIST(UPPER(ALLTRIM(scc)),'X')
		ENDIF
		
		SELECT rul_temp
		REPLACE ALL dataact WITH loActactan.dataact, ;
			nnir WITH loActactan.nnir, ;
			id_sectie WITH loActactan.id_sectie, ;
			id_responsabil WITH loActactan.id_responsabil, ;
			id_lucrare WITH loActactan.id_lucrare
		
		
		IF USED('crsNota')
			USE IN crsNota
		ENDIF
		
		
		&& ordonez notele contabile in ACTACTAN
		SELECT actactan
		SUM suma TO lnSume
		
		IF lnSume <> 0
			lcCondDele = [!(suma = 0 and !(((left(scd,1) = '3' and left(scc,2) = '40') OR (left(scd,2) = '41' and left(scc,1) = '7')) AND proc_tva # 1))]
		ELSE
			lcCondDele = [suma = 0 AND nr_nota = 1 ]
		ENDIF
		SELECT * FROM actactan INTO CURSOR crsActActan WHERE &lcCondDele OR INLIST(id_set, 89, 210, 211, 212) ORDER BY nr_nota NOFILTER READWRITE
		
		SELECT actactan
		DELETE FROM actactan
		APPEND FROM DBF('crsactactan')
		IF USED('crsactactan')
			USE IN crsActActan
		ENDIF
		
		&& completare analitice
		
		SELECT actactan
		SCAN FOR EMPTY(NVL(ascd,''))
			SCATTER NAME loActactan
			IF TYPE('loActactan.cont') = 'U'
				x = ADDPROPERTY(loActactan,'cont',loActactan.scd)
			ENDIF
			IF oset.model = 2 AND TYPE('loActactan.id_gestiune') = 'U'              && NIR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestin)
			ENDIF
			IF INLIST(oset.model, 3, 4) AND TYPE('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestout)
			ENDIF
			loActactan.ascd = THIS.assign_analitic(loActactan.scd,THIS.cobj,'loActactan')
			REPLACE ascd WITH loActactan.ascd
			SELECT actactan
		ENDSCAN
		
		SELECT actactan
		SCAN FOR EMPTY(NVL(ascc,''))
			SCATTER NAME loActactan
			IF TYPE('loActactan.cont') = 'U'
				x = ADDPROPERTY(loActactan,'cont',loActactan.scc)
			ENDIF
			IF oset.model = 2 AND TYPE('loActactan.id_gestiune') = 'U'              && NIR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestin)
			ENDIF
			IF INLIST(oset.model, 3, 4) AND TYPE('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestout)
			ENDIF
			loActactan.ascc = THIS.assign_analitic(loActactan.scc,THIS.cobj,'loActactan')
			REPLACE ascc WITH loActactan.ascc
			SELECT actactan
		ENDSCAN
		
		
		IF TYPE('loActactan') = 'O'
			RELEASE loActactan
		ENDIF
		
		SELECT actactan
		GO TOP
		
		RETURN .T.
		
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		
		LOCAL lcCtrGrid, lcCtrCriteriu, lcControl
		lcCtrGrid = []
		lcCtrCriteriu = []
		
		lcControl = UPPER(this.ActiveControl.Name)
		IF lcControl = '_GRID1'
			lcCtrGrid = UPPER(this.ActiveControl.comment)
		ENDIF 
		IF lcControl = 'CRITERIU'
			lcCtrCriteriu = UPPER(this.ActiveControl.comment)
		ENDIF 
		
		IF nkeyCode = 13 AND 'GRD_ST' $ lcCtrGrid
			NODEFAULT
			thisform.urmator1.comMAND1.SetFocus 
		ENDIF 
		
		IF nkeyCode = 13 AND 'GRD_DR' $ lcCtrGrid
			NODEFAULT
			*thisform.ct_grid_search1.Cb_tx_cautare1.text.SetFocus 
		ENDIF 
		
		If (nKeyCode >=33 And nKeyCode <=122) And ('CRITERIU_ST' $ lcCtrCriteriu OR 'GRD_ST' $ lcCtrGrid)
			Nodefault
			This.ct_grid_search1.Cb_tx_cautare1.Text.Value = Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value) + Chr(nKeyCode)
			This.ct_grid_search1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		If (nKeyCode = 127) And ('CRITERIU_ST' $ lcCtrCriteriu OR 'GRD_ST' $ lcCtrGrid) && backspace
			Nodefault
			This.ct_grid_search1.Cb_tx_cautare1.Text.Value = Left(Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value),Len(Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value))-1)
			This.ct_grid_search1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		Endif
		
		If (nKeyCode >=33 And nKeyCode <=122) And ('CRITERIU_DR' $ lcCtrCriteriu OR 'GRD_DR' $ lcCtrGrid)
			Nodefault
			This.ct_grid_order1.Cb_tx_cautare1.Text.Value = Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value) + Chr(nKeyCode)
			This.ct_grid_order1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		If (nKeyCode = 127) And ('CRITERIU_DR' $ lcCtrCriteriu OR 'GRD_DR' $ lcCtrGrid) && backspace
			Nodefault
			This.ct_grid_order1.Cb_tx_cautare1.Text.Value = Left(Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value),Len(Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value))-1)
			This.ct_grid_order1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		*If (nKeyCode = 27) && esc
			DoDefault(nKeyCode, nShiftAltCtrl)
		*Endif
	ENDPROC

	PROCEDURE make_rultemp
		&& completez RUL_TEMP
		
		lcStoc = this.grid_web.RecordSource
		
		IF USED('rul_temp')
			USE IN rul_temp
		ENDIF
		
		* lcRul = ALLTRIM(THIS.osel_dr.cfrom)
		lcSql = [select v.*, v.id_gestiune as id_gestin, v.nume_gestiune as gestin, v.id_gestiune as id_gestout,] + ;
			[v.nume_gestiune as gestout, 0 as nuInConturiX from ] + gcS + [.vrul v where 1=2]
		lcCursor = [rul_temp]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		ENDIF 
		
		lcSql = [select id_articol, id_gestiune, pret, proc_tvav, cont, acont, SUM(cants + cant - cante) as stoc ] + ;
			[from stoc where an = ] + TRANSFORM(gnAn) + [ and luna = ] + TRANSFORM(gnLuna) + ;
			[ and id_gestiune in (] + TRANSFORM(poAct.id_gestiune) + [)] + gcCondSucursala + ; 
			[ group by id_articol, id_gestiune, pret, proc_tvav, cont, acont order by pret]
		lcCursor = [crsStocActual1]	
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		ENDIF 
		
		SELECT * FROM crsStocActual1 ;
			WITH (buffering = .T.) ;
			INTO CURSOR crsStocActual ;
			readwrite
		
		USE IN crsStocActual1
		
		SELECT id_articol, cante, pretvtva, proc_tvav ;
			FROM (lcStoc) ;
			WHERE CANTE > 0 ;
			INTO CURSOR crsStocTemp ;
			READWRITE 
			
		SELECT crsStocTemp
		SCAN 
			lnCantRamas = cante
			lnIdArticol = id_articol
			lnPretvtva = pretvtva
			lnProcTvav = IIF(proc_tvav > 0, proc_tvav, 1)
			lnPretv = ROUND(lnPretvtva / lnProcTvav, gnPpret)
			lnTvav = lnPretvtva - lnPretv
			
			SELECT crsStocActual
			LOCATE FOR id_articol = lnIdArticol AND stoc > 0 AND lnCantRamas > 0
			DO WHILE FOUND()
				lnCante = MIN(lnCantRamas, stoc)
				lnCantRamas = lnCantRamas - lnCante
				lnPret = pret
				lnIdGestiune = id_gestiune
				lcCont = cont
				lcAcont = acont
				lnAdaos = lnPretv - lnPret	
				lnAdaosTva = ROUND(lnAdaos * IIF(lnProcTvav <> 0, lnProcTvav-1,0),max(gnPpret,gnPPretV)) 
						
				REPLACE stoc WITH stoc - lnCante
				
				SELECT rul_temp
				SCATTER NAME loRul BLANK 
				WITH loRul
					.id_articol = lnIdArticol
					.id_gestout = lnIdGestiune
					.id_gestiune = lnIdGestiune
					.cante = lnCante
					.pret = lnPret
					.pretvtva = lnPretvtva
					.proc_tvav = lnProcTvav
					.pretv = lnPretv
					.proc_tva = lnProcTvav
					.cont = lcCont
					.acont = lcAcont
					.adaos = lnAdaos
					.adaos_tva = lnAdaosTva
				ENDWITH 
				SELECT rul_temp
				APPEND BLANK
				GATHER NAME loRul 
				
				SELECT crsStocActual
				LOCATE FOR id_articol = lnIdArticol AND stoc > 0 AND lnCantRamas > 0		
			ENDDO 
		ENDSCAN
		
		
		
		
		
		
			
			
			
		
	ENDPROC

	PROCEDURE Release
		IF USED("cWeb_vanzari")
			USE IN cWeb_vanzari
		ENDIF 
	ENDPROC

	PROCEDURE cboListe.Valid
		pnId_lista = cListePret.id_pol
		
	ENDPROC

	PROCEDURE grid_web.Column7.Text1.Valid
		LOCAL lcTabel, lnCant_vand, lnCant_in_stoc
		lcTabel = THISFORM.grid_web.RECORDSOURCE
		STORE 0 TO lnCant_vand, lnCant_in_stoc
		
		SELECT (lcTabel)
		lnCant_vand = cant_vand
		lnCant_in_stoc = cant_in_stoc
		lnCant_Max = MIN(lnCant_vand, lnCant_in_stoc)
		lnCante = cante
		
		IF lnCante > lnCant_Max 
			WAIT WINDOW 'Nu puteti scoate o cantitate mai mare decat cea aflata in stoc/vanduta !' NOWAIT
			lnCante = lnCant_Max 
			REPLACE cante WITH lnCante
		ENDIF
		
		SELECT (lcTabel)
		REPLACE cant_ramasa_de_scazut WITH cant_vand - lnCante, ;
			val_vand WITH pretvtva * lnCante
		THISFORM.grid_web.REFRESH
	ENDPROC

	PROCEDURE grid_web.Init
		this.SetAll("DynamicBackColor","IIF(cant_vand > cant_in_stoc, RGB(255,205,155), RGB(255,255,255))", "Column")
	ENDPROC

	PROCEDURE Lb_titlu_alb_b121.Init
		IF TYPE('oxset.nume_set') # 'U'
			this.Caption = PROPER(ALLTRIM(oxset.nume_set))
		ENDIF 
	ENDPROC

	PROCEDURE txtDataF.Valid
		pdDataF = this.value 
		
		
	ENDPROC

	PROCEDURE txtDataI.Valid
		pdDataI = this.value 
	ENDPROC

	PROCEDURE _shape1.DblClick
		IF thisform.WindowState = 2
			thisform.WindowState = 0
		ELSE 
			thisform.WindowState = 2 
		ENDIF 
	ENDPROC

ENDDEFINE

DEFINE CLASS webnir_pretvanzare 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="_shapeSus" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboListe" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column6.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column6.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column7.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column7.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column8.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column8.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column11.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column11.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_factura1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataI" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: aleg_cont_transfer
		*m: assign_analitic
		*m: assign_values
		*m: calcul_pret_vanzare
		*m: calcul_sume
		*m: caut_gestiune
		*m: compensare
		*m: do_alege_lista_preturi
		*m: make_rultemp
		*p: cfrm_ceredate
		*p: cobj
		*p: ctip_frm
		*p: ntotal
		*p: osel_dr
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton3 = 
		cbuton4 = Ct_grid_order1.But_sterge1;but_reface1
		cfrm_ceredate = 
		cobj = 
		ctip_frm = NIR
		DoCreate = .T.
		Height = 572
		lactiv1 = .T.
		lactiv3 = .T.
		lactiv4 = .T.
		Name = "webnir_pretvanzare"
		ntotal = 0
		osel_dr = 
		Width = 793
		WindowType = 1
		_shape1.Anchor = 11
		_shape1.Height = 30
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Tag = ""
		_shape1.Top = -1
		_shape1.Width = 726
		_shape1.ZOrderSet = 0
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 724
		_shape2.Name = "_shape2"
		_shape2.Tag = "MOVABLE"
		_shape2.Top = 0
		_shape2.Width = 69
		_shape2.ZOrderSet = 1
		Lb_titlu_alb_b121.Anchor = 3
		Lb_titlu_alb_b121.FontName = "Comic Sans MS"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Height = 20
		Lb_titlu_alb_b121.Left = 10
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 8
		Lb_titlu_alb_b121.Top = 3
		Lb_titlu_alb_b121.Width = 41
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 757
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 6
		BUT_TERMIN1.Tag = ""
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 32
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT '_shapeSus' AS _shape WITH ;
		Anchor = 11, ;
		BackStyle = 0, ;
		BorderColor = 7,118,177, ;
		BorderWidth = 2, ;
		Height = 103, ;
		Left = 8, ;
		Name = "_shapeSus", ;
		Tag = "RESIZABLE, MOVABLE", ;
		Top = 35, ;
		Width = 780, ;
		ZOrderSet = 4
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="shape" />

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

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

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 9, ;
		Left = 727, ;
		Name = "But_renunt1", ;
		TabIndex = 7, ;
		Tag = "", ;
		Top = 1, ;
		ZOrderSet = 5
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cboListe' AS combobox WITH ;
		Anchor = 3, ;
		ColumnCount = 4, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,65,60,0", ;
		Format = "", ;
		Height = 24, ;
		Left = 66, ;
		Name = "cboListe", ;
		RowSource = "cListePret.nume_lista_preturi,datai,datas,id_pol", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 1, ;
		Top = 147, ;
		Width = 229, ;
		ZOrderSet = 11
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 3, ;
		Left = 295, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 4, ;
		Top = 172
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Ct_factura1' AS ct_factura WITH ;
		Anchor = 131, ;
		Left = 14, ;
		Name = "Ct_factura1", ;
		TabIndex = 9, ;
		Tag = "", ;
		Top = 52, ;
		ZOrderSet = 13, ;
		lbBaza.Name = "lbBaza", ;
		lbTva.Name = "lbTva", ;
		txBaza.Name = "txBaza", ;
		txTva.Name = "txTva", ;
		lbExplic.Name = "lbExplic", ;
		txTotal.Name = "txTotal", ;
		lbTotal.Name = "lbTotal"
		*< END OBJECT: ClassLib="ferestre_cere_date.vcx" BaseClass="container" />

	ADD OBJECT 'grid_web' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 9, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 38, ;
		Height = 348, ;
		HighlightStyle = 2, ;
		Left = 8, ;
		Name = "grid_web", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "cWeb_vanzari", ;
		TabIndex = 5, ;
		Top = 206, ;
		Width = 778, ;
		ZOrderSet = 20, ;
		Column1.ControlSource = "nr_crt", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Format = "rk", ;
		Column1.InputMask = "9999", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 26, ;
		Column2.ControlSource = "codmat", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 44, ;
		Column3.ControlSource = "denumire", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 216, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "cant_vand", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(7,gnPCant)), ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 48, ;
		Column5.ColumnOrder = 4, ;
		Column5.ControlSource = "pretvtva", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPPretV)), ;
		Column5.Name = "Column5", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 71, ;
		Column6.ControlSource = "cant_in_stoc", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.Format = "rk", ;
		Column6.InputMask = (get_mask(7,gnPCant)), ;
		Column6.Name = "Column6", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 52, ;
		Column7.BackColor = 223,248,255, ;
		Column7.ControlSource = "cante", ;
		Column7.DynamicBackColor = "223,248,255", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.Format = "rk", ;
		Column7.InputMask = (get_mask(7,gnPCant)), ;
		Column7.Name = "Column7", ;
		Column7.ReadOnly = .F., ;
		Column7.Width = 53, ;
		Column8.ColumnOrder = 9, ;
		Column8.ControlSource = "val_vand", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.Format = "rk", ;
		Column8.InputMask = (get_mask(7,gnPA)), ;
		Column8.Name = "Column8", ;
		Column8.ReadOnly = .F., ;
		Column8.Width = 94, ;
		Column9.ColumnOrder = 8, ;
		Column9.ControlSource = "cant_ramasa_de_scazut", ;
		Column9.FontName = "Arial Narrow", ;
		Column9.Format = "rk", ;
		Column9.InputMask = (get_mask(7,gnPCant)), ;
		Column9.Name = "Column11", ;
		Column9.ReadOnly = .F.
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. crt.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column11.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate ramasa de scazut", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column11.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod mat.", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate vanduta", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret de vanzare (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column6.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column7.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate ce se scade", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column7.Text1' AS textbox WITH ;
		BackColor = 223,248,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F.
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grid_web.Column8.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare vanduta ce se scade (cu TVA)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web.Column8.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial Narrow", ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1"
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada", ;
		Height = 17, ;
		Left = 8, ;
		Name = "Label1", ;
		TabIndex = 10, ;
		Top = 177, ;
		Width = 52, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "-", ;
		Height = 17, ;
		Left = 176, ;
		Name = "Label2", ;
		TabIndex = 11, ;
		Top = 177, ;
		Width = 6, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Punct vanzare", ;
		Height = 32, ;
		Left = 8, ;
		Name = "Label3", ;
		TabIndex = 12, ;
		Top = 143, ;
		Width = 44, ;
		WordWrap = .T., ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDataF' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataF", ;
		Format = "k", ;
		Height = 23, ;
		Left = 184, ;
		Name = "txtDataF", ;
		TabIndex = 3, ;
		Top = 174, ;
		Width = 109, ;
		ZOrderSet = 18
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtDataI' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataI", ;
		Format = "k", ;
		Height = 23, ;
		Left = 65, ;
		Name = "txtDataI", ;
		TabIndex = 2, ;
		Top = 174, ;
		Width = 109, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE aleg_cont_transfer
	ENDPROC

	PROCEDURE assign_analitic
	ENDPROC

	PROCEDURE assign_values
	ENDPROC

	PROCEDURE calcul_pret_vanzare
		PARAMETERS tcTabel
		
		LOCAL lnPretv, lnTvav, lnCoefAdaos, lnSuma, lcTabel
		STORE 0 TO lnPretv, lnTvav, lnCoefAdaos, lnSuma
		
		IF EMPTY(tcTabel)
			lcTabel = this.ct_grid_order1.cnumecursor 
		ELSE 
			lcTabel = ALLTRIM(tcTabel)
		ENDIF 
		
		SELECT (lcTabel)
		SUM ROUND(ABS(cante*pret),gnPc) TO lnSuma
		
		IF lnSuma <> 0
			lnCoefAdaos = (pcobj.totftva-lnSuma)/lnSuma  && coeficientul mediu de adaos
		ELSE 
			lnCoefAdaos = 1
		ENDIF 
		
		SELECT (lcTabel)
		SET FILTER TO 
		REPLACE ALL proc_tvav WITH pcobj.proc_tva, procent WITH ROUND(lnCoefAdaos*100,2)
		CALCULATE cnt() TO lnRecords
		i = 0
		SCAN 
			i = i + 1
			REPLACE pretv WITH pret + ROUND(pret*lnCoefAdaos,gnPpret) 
			REPLACE tvav WITH ROUND(pretv*(proc_tvav-1),gnPpret)
			lnPretv = lnPretv + ROUND(pretv*cante,gnPC)
			lnTvav = lnTvav + ROUND(tvav*cante,gnPC)
			IF i = lnRecords
				IF lnPretv # pcobj.totftva 
					REPLACE pretv WITH pretv + ROUND((pcobj.totftva - lnPretv)/cante,gnPpret)
				ENDIF 
				IF lnTvav # pcobj.tottva
					REPLACE tvav WITH tvav + ROUND((pcobj.tottva - lnTvav)/cante,gnPpret)
				ENDIF 
			ENDIF 
		ENDSCAN 
		
	ENDPROC

	PROCEDURE calcul_sume
		PARAMETERS tcTabel
		STORE 0 TO lnTotBaza, lnTotTva, lnBazaDiscount, lnBazaAdaos, lnTvaDiscount, lnTvaAdaos
		
		lcCant = this.osel_dr.cantitate
		IF PCOUNT() = 0
			tcTabel =  ALLTRIM(THIS.ct_grid_order1.cnumecursor)
		ENDIF
		
		SELECT (tcTabel)
		SUM ROUND(&lcCant*PRET,gnPc) TO THISFORM.ntotal
		lnTotBaza = THISFORM.ntotal
		
		WAIT WINDOW ALLTRIM(STR(lnTotBaza))  
		
		SUM ROUND(ROUND(&lcCant*PRET,gnPc) * (proc_tva-1),gnPc) TO lnTotTva
		
		THIS.txNir.REFRESH
		THIS.ct_factura1.REFRESH
		THIS.ct_adaos1.REFRESH
		
	ENDPROC

	PROCEDURE caut_gestiune
	ENDPROC

	PROCEDURE compensare
	ENDPROC

	PROCEDURE do_alege_lista_preturi
	ENDPROC

	PROCEDURE Init
		this.WindowState = 2
		DODEFAULT()
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		
		LOCAL lcCtrGrid, lcCtrCriteriu, lcControl
		lcCtrGrid = []
		lcCtrCriteriu = []
		
		lcControl = UPPER(this.ActiveControl.Name)
		IF lcControl = '_GRID1'
			lcCtrGrid = UPPER(this.ActiveControl.comment)
		ENDIF 
		IF lcControl = 'CRITERIU'
			lcCtrCriteriu = UPPER(this.ActiveControl.comment)
		ENDIF 
		
		IF nkeyCode = 13 AND 'GRD_ST' $ lcCtrGrid
			NODEFAULT
			thisform.urmator1.comMAND1.SetFocus 
		ENDIF 
		
		IF nkeyCode = 13 AND 'GRD_DR' $ lcCtrGrid
			NODEFAULT
			*thisform.ct_grid_search1.Cb_tx_cautare1.text.SetFocus 
		ENDIF 
		
		If (nKeyCode >=33 And nKeyCode <=122) And ('CRITERIU_ST' $ lcCtrCriteriu OR 'GRD_ST' $ lcCtrGrid)
			Nodefault
			This.ct_grid_search1.Cb_tx_cautare1.Text.Value = Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value) + Chr(nKeyCode)
			This.ct_grid_search1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		If (nKeyCode = 127) And ('CRITERIU_ST' $ lcCtrCriteriu OR 'GRD_ST' $ lcCtrGrid) && backspace
			Nodefault
			This.ct_grid_search1.Cb_tx_cautare1.Text.Value = Left(Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value),Len(Alltrim(This.ct_grid_search1.Cb_tx_cautare1.Text.Value))-1)
			This.ct_grid_search1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		Endif
		
		If (nKeyCode >=33 And nKeyCode <=122) And ('CRITERIU_DR' $ lcCtrCriteriu OR 'GRD_DR' $ lcCtrGrid)
			Nodefault
			This.ct_grid_order1.Cb_tx_cautare1.Text.Value = Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value) + Chr(nKeyCode)
			This.ct_grid_order1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		If (nKeyCode = 127) And ('CRITERIU_DR' $ lcCtrCriteriu OR 'GRD_DR' $ lcCtrGrid) && backspace
			Nodefault
			This.ct_grid_order1.Cb_tx_cautare1.Text.Value = Left(Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value),Len(Alltrim(This.ct_grid_order1.Cb_tx_cautare1.Text.Value))-1)
			This.ct_grid_order1.Cb_tx_cautare1.Text.SetFocus
			Keyboard '{END}'
		ENDIF
		
		*If (nKeyCode = 27) && esc
			DoDefault(nKeyCode, nShiftAltCtrl)
		*Endif
	ENDPROC

	PROCEDURE Load
		LOCAL lcSql
		lcSql = [select id_calc, denumire from vcalculatoare order by denumire]
		lnSucces = goExecutor.oExecute(lcSql, "cListaCalculatoare")
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.prelucreaza_eroare(), 0+16, "Eroare")
			CREATE CURSOR cListaCalculatoare (id_calc n(5), denumire c(100))
		ENDIF 
		
	ENDPROC

	PROCEDURE make_rultemp
	ENDPROC

	PROCEDURE Release
		USE IN SELECT('cListaCalculatoare')
	ENDPROC

	PROCEDURE cboListe.Valid
		pnId_lista = cListePret.id_pol
		
	ENDPROC

	PROCEDURE grid_web.Column7.Text1.Valid
		LOCAL lcTabel, lnCant_vand, lnCant_in_stoc
		lcTabel = THISFORM.grid_web.RECORDSOURCE
		STORE 0 TO lnCant_vand, lnCant_in_stoc
		
		SELECT (lcTabel)
		lnCant_vand = cant_vand
		lnCant_in_stoc = cant_in_stoc
		lnCant_Max = MIN(lnCant_vand, lnCant_in_stoc)
		lnCante = cante
		
		IF lnCante > lnCant_Max 
			WAIT WINDOW 'Nu puteti scoate o cantitate mai mare decat cea aflata in stoc/vanduta !' NOWAIT
			lnCante = lnCant_Max 
			REPLACE cante WITH lnCante
		ENDIF
		
		SELECT (lcTabel)
		REPLACE cant_ramasa_de_scazut WITH cant_vand - lnCante, ;
			val_vand WITH pretvtva * lnCante
		THISFORM.grid_web.REFRESH
	ENDPROC

	PROCEDURE grid_web.Init
		this.SetAll("DynamicBackColor","IIF(cant_vand > cant_in_stoc, RGB(255,205,155), RGB(255,255,255))", "Column")
	ENDPROC

	PROCEDURE Lb_titlu_alb_b121.Init
		IF TYPE('oxset.nume_set') # 'U'
			this.Caption = PROPER(ALLTRIM(oxset.nume_set))
		ENDIF 
	ENDPROC

	PROCEDURE txtDataF.Valid
		pdDataF = this.value 
		
		
	ENDPROC

	PROCEDURE txtDataI.Valid
		pdDataI = this.value 
	ENDPROC

	PROCEDURE _shape1.DblClick
		IF thisform.WindowState = 2
			thisform.WindowState = 0
		ELSE 
			thisform.WindowState = 2 
		ENDIF 
	ENDPROC

ENDDEFINE

DEFINE CLASS webnir_retetar 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="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_materiiPrime" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cboListe" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cbo_idGest_inMarf" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cbo_idGest_inProd" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_cauta1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_retetar.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataI" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDataF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label6" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label7" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column1.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column1.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column3.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column3.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column4.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column4.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column5.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grid_web_reteta.Column5.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />

	#INCLUDE "c:\program files\microsoft visual foxpro 9\foxpro.h"
	*<DefinedPropArrayMethod>
		*m: aleg_cont_transfer
		*m: assign_analitic
		*m: assign_values
		*m: calcul_pret_vanzare
		*m: calcul_sume
		*m: caut_gestiune
		*m: compensare
		*m: do_alege_lista_preturi
		*m: make_rultemp
		*p: cfrm_ceredate
		*p: cobj
		*p: ctip_frm
		*p: lpretvanz
		*p: nidprodus
		*p: npretvtva
		*p: ntotal
		*p: osel_dr
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cbuton3 = 
		cbuton4 = Ct_grid_order1.But_sterge1;but_reface1
		cfrm_ceredate = 
		cobj = 
		ctip_frm = NIR
		DoCreate = .T.
		Height = 572
		lactiv1 = .T.
		lactiv3 = .T.
		lactiv4 = .T.
		lpretvanz = .F.
		Name = "webnir_retetar"
		nidprodus = 0
		npretvtva = 0
		ntotal = 0
		osel_dr = 
		Width = 793
		WindowType = 1
		_shape1.Anchor = 11
		_shape1.Height = 30
		_shape1.Left = -1
		_shape1.Name = "_shape1"
		_shape1.Tag = ""
		_shape1.Top = -1
		_shape1.Width = 726
		_shape1.ZOrderSet = 1
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 724
		_shape2.Name = "_shape2"
		_shape2.Tag = "MOVABLE"
		_shape2.Top = 0
		_shape2.Width = 69
		_shape2.ZOrderSet = 2
		Lb_titlu_alb_b121.Anchor = 3
		Lb_titlu_alb_b121.FontName = "Comic Sans MS"
		Lb_titlu_alb_b121.FontSize = 10
		Lb_titlu_alb_b121.Height = 20
		Lb_titlu_alb_b121.Left = 10
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 13
		Lb_titlu_alb_b121.Top = 3
		Lb_titlu_alb_b121.Width = 41
		Lb_titlu_alb_b121.ZOrderSet = 3
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 757
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 11
		BUT_TERMIN1.Tag = ""
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 32
		BUT_TERMIN1.ZOrderSet = 6
		Gridsort1.Left = 144
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 1
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Anchor = 9, ;
		Left = 695, ;
		Name = "But_excel1", ;
		ToolTipText = "Materii prime cumulate insuficiente in stoc (CTRL+E)", ;
		Top = 1, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

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

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 9, ;
		Left = 727, ;
		Name = "But_renunt1", ;
		TabIndex = 12, ;
		Tag = "", ;
		Top = 1, ;
		ZOrderSet = 5
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'cbo_idGest_inMarf' AS combobox WITH ;
		Anchor = 9, ;
		ColumnCount = 5, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,40,25,15,100", ;
		FontName = "Arial Narrow", ;
		Height = 24, ;
		Left = 627, ;
		Name = "cbo_idGest_inMarf", ;
		RowSource = "crsGestiuni.nume_gestiune,cgest,cont,acont,nume_tip", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 6, ;
		Top = 64, ;
		Width = 147, ;
		ZOrderSet = 11
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cbo_idGest_inProd' AS combobox WITH ;
		Anchor = 9, ;
		ColumnCount = 5, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,40,25,15,100", ;
		FontName = "Arial Narrow", ;
		Height = 24, ;
		Left = 627, ;
		Name = "cbo_idGest_inProd", ;
		RowSource = "crsGestiuni.nume_gestiune,cgest,cont,acont,nume_tip", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 5, ;
		Top = 38, ;
		Width = 147, ;
		ZOrderSet = 12
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cboListe' AS combobox WITH ;
		Anchor = 3, ;
		ColumnCount = 4, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,65,60,0", ;
		Format = "", ;
		Height = 24, ;
		Left = 63, ;
		Name = "cboListe", ;
		RowSource = "cListePret.nume_lista_preturi,datai,datas,id_pol", ;
		RowSourceType = 2, ;
		Style = 2, ;
		TabIndex = 1, ;
		Top = 38, ;
		Width = 235, ;
		ZOrderSet = 10
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'Cmd_cauta1' AS cmd_cauta WITH ;
		Anchor = 3, ;
		Height = 27, ;
		Left = 302, ;
		Name = "Cmd_cauta1", ;
		TabIndex = 4, ;
		Top = 36, ;
		Width = 49, ;
		ZOrderSet = 14
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Command1' AS commandbutton WITH ;
		Anchor = 9, ;
		Caption = "Adauga", ;
		FontBold = .T., ;
		FontName = "Arial Narrow", ;
		Height = 21, ;
		Left = 568, ;
		Name = "Command1", ;
		TabIndex = 10, ;
		Top = 88, ;
		Visible = .F., ;
		Width = 40, ;
		ZOrderSet = 23
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'grid_web' AS _grdrow WITH ;
		Anchor = 7, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial", ;
		HeaderHeight = 38, ;
		Height = 456, ;
		HighlightStyle = 2, ;
		Left = 8, ;
		Name = "grid_web", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "cWeb_vanzari", ;
		TabIndex = 7, ;
		Top = 110, ;
		Width = 443, ;
		ZOrderSet = 22, ;
		Column1.ControlSource = "nr_crt", ;
		Column1.FontName = "Arial", ;
		Column1.Format = "rk", ;
		Column1.InputMask = "9999", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 26, ;
		Column2.ControlSource = "codmat", ;
		Column2.FontName = "Arial", ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 44, ;
		Column3.ControlSource = "denumire", ;
		Column3.FontName = "Arial", ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 181, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "cant_vand", ;
		Column4.FontName = "Arial", ;
		Column4.Format = "rk", ;
		Column4.InputMask = (get_mask(7,gnPCant)), ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 63, ;
		Column5.ColumnOrder = 4, ;
		Column5.ControlSource = "pretvtva", ;
		Column5.FontName = "Arial", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPPretV)), ;
		Column5.Name = "Column5", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 92
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. crt.", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod mat.", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate vanduta", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret de vanzare (cu TVA)", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_reteta' AS _grdrow WITH ;
		Anchor = 11, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		HeaderHeight = 38, ;
		Height = 219, ;
		HighlightStyle = 2, ;
		Left = 456, ;
		Name = "grid_web_reteta", ;
		Panel = 1, ;
		ReadOnly = .F., ;
		RecordSource = "cReteta", ;
		TabIndex = 8, ;
		Top = 110, ;
		Width = 327, ;
		ZOrderSet = 24, ;
		Column1.ControlSource = "denumire", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 94, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "cant_nec", ;
		Column2.Format = "rk", ;
		Column2.InputMask = (get_mask(12,gnPCant)), ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .F., ;
		Column2.Width = 71, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "cant_in_stoc", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(12,gnPCant)), ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .T., ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "um", ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 51, ;
		Column5.ControlSource = "cante", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPCant)), ;
		Column5.Name = "Column5", ;
		Column5.ReadOnly = .F., ;
		Column5.Width = 87
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web_reteta.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.Column1.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 'grid_web_reteta.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate necesara", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_reteta.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.Column3.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 'grid_web_reteta.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_reteta.Column4.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 'grid_web_reteta.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate care se scade", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial", ;
		HeaderHeight = 38, ;
		Height = 221, ;
		HighlightStyle = 2, ;
		Left = 456, ;
		Name = "grid_web_retetar", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "cWeb_vanzari_retetar", ;
		TabIndex = 9, ;
		Top = 345, ;
		Width = 327, ;
		ZOrderSet = 16, ;
		Column1.BackColor = 255,255,255, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial", ;
		Column1.Name = "Column1", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 109, ;
		Column2.BackColor = 255,255,255, ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "cant_nec", ;
		Column2.FontName = "Arial", ;
		Column2.Format = "rk", ;
		Column2.InputMask = (get_mask(10,gnPCant)), ;
		Column2.Name = "Column2", ;
		Column2.ReadOnly = .T., ;
		Column3.BackColor = 255,255,255, ;
		Column3.ControlSource = "cant_in_stoc", ;
		Column3.FontName = "Arial", ;
		Column3.Format = "rk", ;
		Column3.InputMask = (get_mask(10,gnPCant)), ;
		Column3.Name = "Column3", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 67, ;
		Column4.BackColor = 255,255,255, ;
		Column4.ControlSource = "um", ;
		Column4.FontName = "Arial", ;
		Column4.Name = "Column4", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 45, ;
		Column5.ControlSource = "cante", ;
		Column5.FontName = "Arial", ;
		Column5.Format = "rk", ;
		Column5.InputMask = (get_mask(10,gnPCant)), ;
		Column5.Name = "Column5", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 84
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grid_web_retetar.Column1.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.Column2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate necesara", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.Column3.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate in stoc", ;
		FontName = "Arial", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.Column4.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "UM", ;
		FontName = "Arial", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT 'grid_web_retetar.Column5.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate care se scade", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grid_web_retetar.Column5.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 'Label1' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Perioada", ;
		Height = 17, ;
		Left = 8, ;
		Name = "Label1", ;
		TabIndex = 15, ;
		Top = 69, ;
		Width = 52, ;
		ZOrderSet = 7
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "-", ;
		Height = 17, ;
		Left = 192, ;
		Name = "Label2", ;
		TabIndex = 18, ;
		Top = 68, ;
		Width = 6, ;
		ZOrderSet = 15
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label3' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Lista de preturi", ;
		Height = 32, ;
		Left = 8, ;
		Name = "Label3", ;
		TabIndex = 19, ;
		Top = 34, ;
		Width = 46, ;
		WordWrap = .T., ;
		ZOrderSet = 21
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label4' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Gestiunea in care", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 543, ;
		Name = "Label4", ;
		TabIndex = 20, ;
		Top = 34, ;
		Width = 73, ;
		WordWrap = .T., ;
		ZOrderSet = 20
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Materii prime cumulate", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 458, ;
		Name = "Label5", ;
		TabIndex = 17, ;
		Top = 329, ;
		Width = 96, ;
		ZOrderSet = 9
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label6' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "intra marfurile", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 543, ;
		Name = "Label6", ;
		TabIndex = 21, ;
		Top = 70, ;
		Width = 55, ;
		WordWrap = .T., ;
		ZOrderSet = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label7' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "intra produsele", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 543, ;
		Name = "Label7", ;
		TabIndex = 20, ;
		Top = 45, ;
		Width = 60, ;
		WordWrap = .T., ;
		ZOrderSet = 20
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label8' AS label WITH ;
		Anchor = 9, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Gestiunea in care", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 543, ;
		Name = "Label8", ;
		TabIndex = 20, ;
		Top = 61, ;
		Width = 73, ;
		WordWrap = .T., ;
		ZOrderSet = 20
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lb_materiiPrime' AS label WITH ;
		Anchor = 3, ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Materii prime", ;
		FontName = "Arial Narrow", ;
		Height = 18, ;
		Left = 458, ;
		Name = "lb_materiiPrime", ;
		TabIndex = 16, ;
		Top = 94, ;
		Width = 56, ;
		ZOrderSet = 8
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDataF' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataF", ;
		Format = "K", ;
		Height = 23, ;
		Left = 197, ;
		Name = "txtDataF", ;
		TabIndex = 3, ;
		Top = 66, ;
		Width = 128, ;
		ZOrderSet = 18
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtDataI' AS textbox WITH ;
		Anchor = 3, ;
		ControlSource = "pdDataI", ;
		Format = "K", ;
		Height = 23, ;
		Left = 63, ;
		Name = "txtDataI", ;
		TabIndex = 2, ;
		Top = 66, ;
		Width = 128, ;
		ZOrderSet = 17
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Activate
		this.WindowState = 2
	ENDPROC

	PROCEDURE actualizeaza_grid2
		save_grid_tag(THISFORM.grid_web_retetar)
		
		SELECT id_material, denumire, ;
			SUM(cant_nec) AS cant_nec, ;
			SUM(cante) AS cante, ;
			cant_in_stoc, um, ;
			adaugat ;
			FROM cReteta ;
			WITH (BUFFERING = .T.) ;
			GROUP BY id_material, denumire, cant_in_stoc, um, adaugat ;
			ORDER BY denumire ;
			INTO CURSOR cweb_vanzari_retetar READWRITE
		
		SELECT id_material, denumire, ;
			SUM(cant_nec) AS cant_nec, ;
			SUM(cante) AS cante, ;
			cant_in_stoc, um ;
			FROM cReteta ;
			WITH (BUFFERING = .T.) ;
			GROUP BY id_material, denumire, cant_in_stoc, um ;
			ORDER BY denumire ;
			INTO CURSOR cTest READWRITE
		
		SELECT cweb_vanzari_retetar
		SCAN FOR adaugat = 1
			lnId_material = id_material
			SELECT cTest
			LOCATE FOR id_material = lnId_material
			IF FOUND()
				lnCante = cante
				UPDATE cweb_vanzari_retetar SET cante = lnCante WHERE id_material = lnId_material
			ENDIF
			SELECT cweb_vanzari_retetar
		ENDSCAN 
		
		IF USED("cTest")
			USE IN cTest 
		ENDIF  
		
		*!*	SELECT cweb_vanzari_retetar
		*!*	REPLACE ALL cante WITH MIN(cant_nec, cant_in_stoc)
		SELECT cweb_vanzari_retetar
		GO TOP
		
		restore_grid_tag(THISFORM.grid_web_retetar)
		THISFORM.grid_web_retetar.REFRESH
		
	ENDPROC

	PROCEDURE aleg_cont_transfer
		PARAMETERS tnIdGest
		lcSql = [select (case when p.explicatie is null then s.explicatie else p.explicatie end) as explicatie,] +;
				[c.cont, p.acont from VCORESP_CONT_TIPGEST c ] +; 
				[left join vplcont_analitic p on c.cont = p.cont and p.an = ?gnAn ] +;
				[left join vplcont_sintetic s on c.cont = s.cont and s.an = ?gnAn]
		pcFiltruOrig = [c.id_tipgest in (select nr_pag from vnom_gestiuni where id_gestiune = ?tnIdGest)]
		pcfiltru = [1=2]
		pcschema = []
		pcorder = [cont,acont]
		pccoloane = [cont,acont,explicatie]
		pcTitlu = [Alegeti Contul de Transfer] 
		pcTitluColoane = [Cont,Analitic,Explicatie cont]
		locauta = cauta_alfa(lcSql,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,'',.F.,pcFiltruOrig)	&& 11.07.2007
			
		RETURN loCauta
	ENDPROC

	PROCEDURE assign_analitic
		PARAMETERS tcCont,pcAct,pcRul
		
		PRIVATE pcCont,pcAct,pcRul,pParamP,pParamS
		STORE 0 TO pParamP,pParamS
		lcAnalitic = ''
		lcAlias = ALIAS()
		
		pcCont = ALLTRIM(tcCont)
		
		lcSel = [SELECT * from ] + gcs + [.config_analitice WHERE cont = ?pcCont]
		lcCursor = 'crs_cfg_ana'
		lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		IF lnSucces < 0
			amessagebox(goExecutor.cEroare,0+16,"Eroare")
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_cfg_ana')=0
				USE IN crs_cfg_ana
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			SELECT crs_cfg_ana
			SCATTER NAME ocfg
			lcCampPrefix = NVL(ALLTRIM(ocfg.camp_leg_prefix),'')
			lcCampSufix = NVL(ALLTRIM(ocfg.camp_leg_sufix),'')
			
			IF !EMPTY(lcCampPrefix)
				IF TYPE('&pcRul..'+lcCampPrefix) # 'U'
					pParamP = &pcRul..&lcCampPrefix
				ELSE 
					IF TYPE('&pcAct..'+lcCampPrefix) # 'U'
						pParamP = &pcAct..&lcCampPrefix
					ENDIF 
				ENDIF 
			ENDIF 
			
			IF !EMPTY(lcCampSufix)
				IF TYPE('&pcRul..'+lcCampSufix) # 'U'
					pParamS = &pcRul..&lcCampSufix 
				ELSE 
					IF TYPE('&pcAct..'+lcCampSufix) # 'U'
						pParamS = &pcAct..&lcCampSufix 
					ENDIF 
				ENDIF 
			ENDIF 
		
			lcSel = [{call fconturi_analitice(?gcs,?pcCont,0,?pParamP,?pParamS)}]
			lcCursor = 'crs_analitice'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
		
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		&& iau Primul Simbol Analitic din Tabel - ordonat pt ca e selectat cu Distinct
		IF lnSucces > 0
			SELECT crs_analitice
			GO top
			lcAnalitic = ALLTRIM(acont)
		ENDIF 
		
		&& verificare analiticului cu Planul de Conturi
		IF lnSucces > 0
			lcSel = [SELECT cont,acont from ] + gcs + [.vplcont_analitic WHERE cont = ?pcCont and acont = ?lcAnalitic and an = ?gnAn ]
			lcCursor = 'crs_verific'
			lnSucces = goExecutor.oExecute(lcSel,lcCursor)
			IF lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
			ENDIF 
		ENDIF 
		
		IF lnSucces > 0
			IF RECCOUNT('crs_verific')=0
				lnSucces = -1
			ENDIF 
		ENDIF 
		
		IF USED('crs_cfg_ana')
			USE IN crs_cfg_ana
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		IF USED('crs_analitice')
			USE IN crs_analitice
		ENDIF 
		IF USED('crs_verific')
			USE IN crs_verific
		ENDIF 
		
		IF lnSucces < 0
			lcAnalitic = ''
		ENDIF 
		
		SELECT (lcAlias)
		RETURN lcAnalitic
		
	ENDPROC

	PROCEDURE assign_values
		PARAMETERS tcObjDestinatie, tcObjSursa1, tcObjSursa2
		
		* lcSelRul = this.ct_grid_order1.cnumecursor 
		
		lcOdest = ALLTRIM(tcObjDestinatie)
		lcOsursa1 = ALLTRIM(tcObjSursa1)
		lcOsursa2 = ALLTRIM(tcObjSursa2)
		
		*!*	SELECT (lcSelRul)
		*!*	FOR i = 1 TO FCOUNT()
		*!*		lcNumeCol = FIELD(i)
		*!*		IF TYPE('&lcOsursa1..'+lcNumeCol) # 'U'
		*!*			&lcodest..&lcNumeCol = &lcosursa1..&lcNumeCol
		*!*		ENDIF 
		*!*		IF TYPE('&lcOsursa2..'+lcNumeCol) # 'U'
		*!*			IF EMPTY(&lcodest..&lcNumeCol)
		*!*				&lcodest..&lcNumeCol = &lcosursa2..&lcNumeCol
		*!*			ENDIF 
		*!*		ENDIF 
		*!*	ENDFOR 
		
		
		
		
		
		 
	ENDPROC

	PROCEDURE calcul_pret_vanzare
		PARAMETERS tcTabel
		
		LOCAL lnPretv, lnTvav, lnCoefAdaos, lnSuma, lcTabel
		STORE 0 TO lnPretv, lnTvav, lnCoefAdaos, lnSuma
		
		IF EMPTY(tcTabel)
			lcTabel = this.ct_grid_order1.cnumecursor 
		ELSE 
			lcTabel = ALLTRIM(tcTabel)
		ENDIF 
		
		SELECT (lcTabel)
		SUM ROUND(ABS(cante*pret),gnPc) TO lnSuma
		
		IF lnSuma <> 0
			lnCoefAdaos = (pcobj.totftva-lnSuma)/lnSuma  && coeficientul mediu de adaos
		ELSE 
			lnCoefAdaos = 1
		ENDIF 
		
		SELECT (lcTabel)
		SET FILTER TO 
		REPLACE ALL proc_tvav WITH pcobj.proc_tva, procent WITH ROUND(lnCoefAdaos*100,2)
		CALCULATE cnt() TO lnRecords
		i = 0
		SCAN 
			i = i + 1
			REPLACE pretv WITH pret + ROUND(pret*lnCoefAdaos,gnPpret) 
			REPLACE tvav WITH ROUND(pretv*(proc_tvav-1),gnPpret)
			lnPretv = lnPretv + ROUND(pretv*cante,gnPC)
			lnTvav = lnTvav + ROUND(tvav*cante,gnPC)
			IF i = lnRecords
				IF lnPretv # pcobj.totftva 
					REPLACE pretv WITH pretv + ROUND((pcobj.totftva - lnPretv)/cante,gnPpret)
				ENDIF 
				IF lnTvav # pcobj.tottva
					REPLACE tvav WITH tvav + ROUND((pcobj.tottva - lnTvav)/cante,gnPpret)
				ENDIF 
			ENDIF 
		ENDSCAN 
		
	ENDPROC

	PROCEDURE calcul_sume
		PARAMETERS tcTabel
		STORE 0 TO lnTotBaza, lnTotTva, lnBazaDiscount, lnBazaAdaos, lnTvaDiscount, lnTvaAdaos
		
		lcCant = this.osel_dr.cantitate
		IF PCOUNT() = 0
			tcTabel =  ALLTRIM(THIS.ct_grid_order1.cnumecursor)
		ENDIF
		
		SELECT (tcTabel)
		SUM ROUND(&lcCant*PRET,gnPc) TO THISFORM.ntotal
		lnTotBaza = THISFORM.ntotal
		
		WAIT WINDOW ALLTRIM(STR(lnTotBaza))  
		
		SUM ROUND(ROUND(&lcCant*PRET,gnPc) * (proc_tva-1),gnPc) TO lnTotTva
		
		* THIS.txNir.REFRESH
		* THIS.ct_factura1.REFRESH
		* THIS.ct_adaos1.REFRESH
		
	ENDPROC

	PROCEDURE caut_gestiune
		PARAMETERS tnFel
		
		IF EMPTY(tnFel)
			tnFel = 0
		ENDIF 
		
		IF tnFel = 1 && pret vanzare
			lcCond = [nr_pag = 6]
		ELSE 
			lcCond = [nr_pag in (2,3,4,5)]
		ENDIF 
		
		pcselect = [select * from vnom_GESTIUNI]
		pcFiltruOrig = [inactiv = 0 and ] + lcCond
		pcfiltru = [1=2]
		pcschema = []
		pcorder = [NUME_gestiune]
		pccoloane = [nume_gestiune,cgest]
		pcTitlu = [Nume Gestiune Destinatie] 
		pcTitluColoane = [Gestiune,Indicativ]
		locauta = cauta_alfa(pcselect,pcfiltru,pcschema,pcorder,pccoloane,pcTitlu,pcTitluColoane,'',.F.,pcFiltruOrig)	&&	11.07.2007
			
		RETURN locauta
	ENDPROC

	PROCEDURE compensare
		IF USED('xcont')
			SELECT xcont
			LOCATE FOR Pozitie # Fel_Cont AND Cu_Inregistrari = 1
			IF FOUND()
				pcContul = ALLTRIM(cont_part)
				pnIdPart = idPart
				pcNume = numepart
				pnFelCont = Fel_Cont
				pcDenumire = ALLTRIM(explic_cont)
		
				pcCond = [ an = ?gnAn and luna = ?gnluna]
		
				llval = .F. && Deocamdata e doar in lei
				IF llval
					pccond= pccond + [ and ABS(i.precvaldeb + i.valdebit - i.precvalcred - i.valcredit)>0 and i.id_valuta = ] + ALLTRIM(STR(&lcObj..id_valuta))
				ELSE
					pccond= pccond + [ and (i.precvaldeb + i.valdebit - i.precvalcred - i.valcredit = 0) ]
				ENDIF
		
		
		
				pcselect = ['select i.* FROM ] + gcs + [.Vireg_parteneri i where 2=2 ']
				pcfiltru = [ i.id_part = ?pnIdPart AND ABS(i.precdeb + i.debit - i.preccred - i.credit)<>0 AND i.cont = ?pcContul and ] + pcCond
				pcschema = ['']
				pcorder = ['']
		
				PRIVATE podateintrod
				STORE '' TO podateintrod
		
				gencursor('podateintrod','crs_actcv',pcselect,pcfiltru,[''],'')
		
				lcFis = 'actcv' + ALLTRIM(pcContul)
		
				IF USED(lcFis)
					USE IN &lcFis
				ENDIF
		
				IF pnFelCont = 0
					lcsel = [SELECT *, ACONT AS ASCC, nume_val as numeval, curs as cursschimb, precdeb + debit as totctva, preccred+credit as achitat, ] +;
						[precvaldeb + valdebit AS sumaval, precVALcred+VALcredit as achitatval, ] +;
						[.f. as ales, 00000000000000.0000 as sumaachi, 000000000000.0000 as sumaachi2, 00000000000000.0000 as achilei, 00000000000000.0000 as difplus, 00000000000000.0000 as difminus, 000000.0000 as cursval, 000000.0000 as cursdif ] +;
						[FROM crs_actcv INTO CURSOR ] + lcFis + [ READWRITE ]
				ELSE
					lcsel = [SELECT *, ACONT AS ASCD, nume_val as numeval, curs as cursschimb, preccred + credit as totctva, precdeb+debit as achitat, ] + ;
						[precvalcred + valcredit as sumaval, precVALdeb+VALdebit as achitatval, ] + ;
						[.f. as ales, 00000000000000.0000 as sumaachi, 00000000000000.0000 as sumaachi2, 00000000000000.0000 as achilei, 00000000000000.0000 as difplus, 00000000000000.0000 as difminus, 000000.0000 as cursval, 000000.0000 as cursdif ] + ;
						[FROM crs_actcv INTO CURSOR ] + lcFis + [ READWRITE ]
				ENDIF
				&lcsel
		
				SELECT (lcFis)
		
				OPLATA=CREATEOBJECT('ocompensari')
				*		oplata.txtNume.value =lcNume
				OPLATA.titlufrumos1.CAPTION = pcDenumire + [: ] + pcNume
				OPLATA.pcFis = lcFis
				OPLATA.SUMA = THIS.ct_factura1.totctva
				OPLATA.pnFelCont = pnFelCont
				OPLATA.SHOW(1)
		
				*!*			SELECT (lcfis)
				*!*			CALCULATE cnt() FOR ales TO LnBife
				*!*			IF LnBife=1
				*!*				LOCATE FOR ALES
				*!*				&M=nract
				*!*			ELSE
				*!*				&M=0
				*!*			ENDIF
			ENDIF
		ENDIF 
	ENDPROC

	PROCEDURE do_adauga
		loas = CREATEOBJECT("frm_alege_din_stoc")
		loas.lb_titlu_alb_b121.caption = "STOC"
		SELECT xsets
		LOCATE FOR id_set = 92 && tnIdSet
		SCATTER NAME oSet
		*!*	modificare JC/JV 2007
		IF gnNeplatitoare_tva = 1
			oSet.id_jtax = oSet.id_jtaxn
			oSet.id_jnetax = oSet.id_jtaxn
		ENDIF
		*!*	modificare JC/JV 2007	^
		lFactura = oSet.factura
		lAdaos = oSet.adaos
		lDiscount = oSet.discount
		lcTipFrm = UPPER(oSet.explicatia)
		llGestout = .f.
		
		SELECT selectii
		LOCATE FOR id_sel = oSet.id_selSt
		IF FOUND()
			SCATTER NAME ost MEMO
		ELSE
			amessagebox('NECONFIGURAT!',48,'Atentie!')
			RETURN 2 && renunt
		ENDIF
		
		lcSelSt = ALLTRIM(ost.cselect) + [ from ] + gcs + [.] + ALLTRIM(ost.cfrom) + [ where ] + ALLTRIM(ost.filtru)
		lcSchemaSt = ALLTRIM(ost.cschema)
		
		WITH loas.ct_grid_search1
			.cselect = lcSelSt
			.cschema = lcSchemaSt
			.cTitlu_coloane = ALLTRIM(ost.titlu_col)
			.cNume_coloane = ALLTRIM(ost.nume_col)
			.cMask = ALLTRIM(ost.mask_col)
			.cFiltruOriginal = lcFiltruOrig
			.cFiltru = ALLTRIM(ost.filtru)
			.cOrder = ALLTRIM(ost.ordine)
			.cTitlu = ALLTRIM(ost.titlu_grid)
			.cb_tx_gestout.VISIBLE = llGestout
			.but_nou1.VISIBLE = llAdMod
			*	.but_modifica1.VISIBLE = llAdMod
		ENDWITH
		
		loas.SHOW(1)
		
		IF buton = 2
			RETURN
		ENDIF
		
		SELECT cursor_curent1
		IF RECCOUNT() > 0
			SCATTER NAME loArticol
			SELECT cReteta
			LOCATE FOR id_material = loArticol.id_articol
			IF !FOUND()
				APPEND BLANK
				REPLACE id_produs WITH pnId_produs, ;
					id_material WITH loArticol.id_articol, ;
					denumire WITH loArticol.denumire, ;
					cant_nec WITH 0, ;
					cant_in_stoc WITH loArticol.cantitate, ;
					um WITH loArticol.um, ;
					adaugat WITH 1
			ENDIF 
		ENDIF
		
		thisform.grid_web_reteta.Refresh 
		thisform.actualizeaza_grid2()
		
		
	ENDPROC

	PROCEDURE do_alege_lista_preturi
		LOCAL lnTotctva, lnTotftva, lnTva
		STORE 0 TO lnTotctva, lnTotftva, lnTva
		
		PRIVATE pnNr_pag
		STORE 0 TO pnNr_pag
		
		IF thisform.lPretVanz
			pnNr_pag = 6
		ELSE
			pnNr_pag = 5
		ENDIF 
		
		IF EMPTY(gcGestPermis)
			AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			RETURN
		ENDIF 
		
		IF EMPTY(pnId_lista)
			AMESSAGEBOX("Alegeti o lista de preturi!",0+48,"Atentie")
			thisform.cboListe.SetFocus()
			RETURN
		ENDIF
		IF EMPTY(pdDataI)
			AMESSAGEBOX("Completati data initiala !",0+48,"Atentie")
			thisform.txtDataI.SetFocus()
			RETURN
		ENDIF
		IF EMPTY(pdDataF)
			AMESSAGEBOX("Completati data finala !",0+48,"Atentie")
			thisform.txtDataF.SetFocus()
			RETURN
		ENDIF
		
		pcPerioada = DTOC(pdDataI) + " - " + DTOC(pdDataF)
		
		save_grid_tag(THISFORM.grid_web)
		*!* lcSel = [{call pack_gest_vanzari.vanzari_stoc(?pnId_lista, ?pdDataI, ?pdDataF, ?gnAn, ?gnLuna, ?pnNr_pag, ?gcGestPermis)}]
		
		lcSel = [{call pack_gest_vanzari.vanzari_stoc(] + TRANSFORM(pnId_lista) + ;
			[,TO_DATE('] +  TTOC(pdDataI,1) + [','YYYYMMDDHH24:MI:SS'), TO_DATE('] + TTOC(pdDataF,1)  + [','YYYYMMDDHH24:MI:SS'),] + ;
			TRANSFORM(gnAn) + [,] + TRANSFORM(gnLuna) + [,] + TRANSFORM(gnTipGest) + [,'] +  ;
			ALLTRIM(TRANSFORM(poAct.id_gestiune)) + [',?gnIdSucursala)}]
		 
		lcCursor = 'cweb_vanzari'
		lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		IF lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			RETURN
		ENDIF
		restore_grid_tag(THISFORM.grid_web)
		
		PRIVATE pcId_produse
		STORE '' TO pcId_produse
		
		SELECT cweb_vanzari
		SCAN
			pcId_produse = pcId_produse + ALLTRIM(STR(id_articol)) + ","
			SELECT cweb_vanzari
		ENDSCAN
		
		IF pcId_produse <> ","
			pcId_produse = SUBSTR(pcId_produse,1,LEN(pcId_produse)-1)
		ENDIF
		
		*MESSAGEBOX(pcId_produse,0+48,"Id_articole") 
		
		***--------
		IF USED("cweb_vanzari_retetar_o")
			USE IN cweb_vanzari_retetar_o
		ENDIF 
		
		*!* lcSel = [{call pack_gest_vanzari.vanzari_retetar(?gnAn, ?gnLuna, ?gcGestPermis, ?pcId_produse)}]
		lcSel = [{call pack_gest_vanzari.vanzari_retetar(] + TRANSFORM(gnAn) + [,] + TRANSFORM(gnLuna) + [,'] + ;
			ALLTRIM(TRANSFORM(poAct.id_gestiune)) + [','] + ALLTRIM(pcId_produse) + [',?gnIdSucursala)}]
		
		lcCursor = 'cweb_vanzari_retetar_o'
		lnSucces = goExecutor.oExecute(lcSel, lcCursor)
		
		IF lnSucces < 0
			amessage(goExecutor.cEroare,0+16,"Eroare")
			RETURN
		ENDIF
		
		SELECT s2.id_produs, s2.id_material, s2.denumire, ;
			s2.cant_mat, ;
			s1.cant_vand, ;
			s1.pretvtva, ;
			ROUND(s2.cant_mat* s1.cant_vand,gnPCant) AS cant_nec, ;
			s2.cant_in_stoc, ;
			s2.um ;
			FROM cweb_vanzari_retetar_o s2 ;
			LEFT JOIN cweb_vanzari s1 ON s1.id_articol = s2.id_produs ;
			INTO CURSOR cReteta_o
		
		save_grid_tag(THISFORM.grid_web_retetar)
		SELECT id_material, denumire,  ;
			SUM(cant_nec) AS cant_nec, ;
			cant_in_stoc, um, ;
			0000000000.00 as cante, ;
			0 as adaugat ;
			FROM cReteta_o ;
			GROUP BY id_material, denumire, cant_in_stoc, um ;
			ORDER BY denumire ;
			INTO CURSOR cweb_vanzari_retetar READWRITE 
			
		restore_grid_tag(THISFORM.grid_web_retetar)
		
		save_grid_tag(thisform.grid_web_reteta)
		SELECT s1.*, s2.cant_nec AS cant_nec_cum, ;
			IIF(s2.cant_nec > s1.cant_in_stoc, 0, s1.cant_nec) as cante, ;
			0 as adaugat ;
			FROM cReteta_o s1 ;
			LEFT JOIN cweb_vanzari_retetar s2 ON s1.id_material = s2.id_material ;
			INTO CURSOR cReteta READWRITE 
		restore_grid_tag(thisform.grid_web_reteta)
		
		SELECT cweb_vanzari
		*!*	modificare	07.11.2012	:	am pus gnPc in loc de gnPa la lnTotftva
		CALCULATE SUM(ROUND(pretvtva*cante,gnPC)), SUM(ROUND(pretvtva/proc_tvav*cante,gnPC)) TO lnTotctva, lnTotftva
		lnTva = lnTotctva - lnTotftva
		
		SELECT cweb_vanzari
		SCAN
			lnId_articol = id_articol
			SELECT cReteta
			LOCATE FOR id_produs = lnId_articol 
			IF !FOUND()
				SELECT cweb_vanzari
				REPLACE nuInRetetar WITH 1
			ENDIF 
		SELECT cweb_vanzari
		ENDSCAN 
		
		SELECT cweb_vanzari
		LOCATE FOR nuInRetetar = 1
		IF FOUND()
			amessagebox("Exista produse care nu au definita fisa tehnologica!",0+48,"Definiti fisa tehnologica!")
		ENDIF 
		
		*!*	THISFORM.ct_factura1.txTotal.VALUE = lnTotctva
		*!*	THISFORM.ct_factura1.txBaza.VALUE = lnTotftva
		*!*	THISFORM.ct_factura1.txTva.VALUE = lnTva
		
		thisform.actualizeaza_grid2()
		THISFORM.REFRESH
		thisform.grid_web.AfterRowColChange
		
		
		
		
		
	ENDPROC

	PROCEDURE do_cauta
		thisform.do_alege_lista_preturi()
	ENDPROC

	PROCEDURE do_excel
		DO export_excel_grid WITH this.grid_web_retetar, 'denumire', "cant_nec > cant_in_stoc" IN proceduri_excel.prg
	ENDPROC

	PROCEDURE do_modifica
		*!*	lcNomArt = this.ct_grid_search1.cnumecursor 
		*!*	SELECT (lcNomArt)
		*!*	SCATTER NAME lorec 	
		
		*!*	PRIVATE poCote_tva
		*!*	STORE '' TO poCote_tva
		*!*		
		*!*	lnId = lorec.id_articol	
		*!*	DO Adauga_Modifica_Inregistrare WITH [catalog_articole],lorec,lnId,[UPDATE]
		*!*	this.ct_grid_search1.actualizeaza_grid
	ENDPROC

	PROCEDURE do_sterge
		LOCAL lnRecno, lcSelRul
		* lcSelRul = this.ct_grid_order1.cnumecursor 
		
		SELECT (lcSelRul)
		*SCATTER NAME osterg
		lnRecno = RECNO()
		DELETE 
		
		*!* MODIFICAT 11.04.2006
		*!* MARIUS.MUTU - AM PUS RECNO('RUL_TEMP') IN CURSORUL DE TRANSFER - LA STERGERE SA POT STERGE SI LINIA CORESPONDENTA DIN CRSTRANSFER	
		
		*!*	IF INLIST(oset.model,5,6) AND USED('crsTransfer')	
		*!*		SELECT crsTransfer
		*!*		GOTO lnRecno
		*!*		DELETE 
		*!*		this.ct_grid_order1.cb_tx_gestin.SetFocus()
		*!*	ENDIF 
		
		*!*	this.ct_grid_order1.actualizeaza_grid 
		*!*	this.calcul_sume
		
		
	ENDPROC

	PROCEDURE do_termin
		IF this.inainte_de_do_termin()
			gnButon = 1
			pnButon = 1
			Buton = 1
			pnIesire = 1
			*this.Hide 
			SELECT actactan
			*!*	modificare ROAGRESTAURANT v 0.0.14
			llVerificare = verificare_note_contabile('actactan', .T.,.T., .F.)
			If !llVerificare
			*!*	modificare ROAGRESTAURANT v 0.0.14	^
				This.AlwaysOnTop = .F.
				Do Form verificare With .T.,.T.,3  && cu buton de precedent
				This.AlwaysOnTop = .T.
			Endif
			
			DO CASE 
				CASE gnButon = 3
					*onirbon.visible = .t.
					* DO nrord WITH lcSelRul
				OTHERWISE 
					this.Release 
			ENDCASE 
		ENDIF 
	ENDPROC

	PROCEDURE inainte_de_do_listare
		thisform.AlwaysOnTop = .F.
		
		LOCAL lcTabel
		lcTabel = thisform.grid_web_retetar.RecordSource
		
		SELECT * FROM (lcTabel) WHERE cant_nec > cant_in_stoc INTO CURSOR cList
		SELECT cList
		REPORT FORM rap_descarcare_retetar TO PRINTER PROMPT PREVIEW  
		IF USED("cList")
			USE IN cList
		ENDIF 
		
		thisform.AlwaysOnTop = .T.
	ENDPROC

	PROCEDURE inainte_de_do_termin
		LOCAL lcSelRul, lcContTr, lcAcontTr, lcRul, lcSql, lcCursor, lnSucces, lcCant
		STORE '' TO lcContTr, lcAcontTr
		
		LOCAL lnRecno
		lnRecno = 0
		
		*** completez tabela ACTACTAN
		IF TYPE('oitem') = 'O'
			IF PEMSTATUS(oitem,'adunadate',5)
				oitem.adunadate()
			ENDIF
		ENDIF
		
		IF EMPTY(gcGestPermis)
			AMESSAGEBOX("Nu aveti drepturi de acces pe nici o gestiune!",0+48,"Atentie")
			RETURN .F.
		ENDIF
		
		IF !USED("cWeb_Vanzari")
			AMESSAGEBOX("Tabelul de vanzari nu contine inregistrari!",0+48,"Atentie")
			RETURN .F.
		ENDIF
		
		SELECT cweb_vanzari
		LOCATE FOR nuInRetetar = 1
		IF FOUND()
			amessagebox("Exista produse care nu au definita fisa tehnologica!",0+48,"Atentie")
			THISFORM.grid_web.SETFOCUS()
			RETURN .F.
		ENDIF
		
		IF EMPTY(pnIdGest_InProd)
			amessagebox("Nu ati completat gestiunea in care intra produsele!",0+48,"Atentie")
			THISFORM.cbo_idGest_inProd.SETFOCUS()
			RETURN .F.
		ENDIF
		
		IF EMPTY(pnIdGest_InMarf)
			amessagebox("Nu ati completat gestiunea in care intra marfurile!",0+48,"Atentie")
			THISFORM.cbo_idGest_inMarf.SETFOCUS()
			RETURN .F.
		ENDIF
		
		lcTabelCum = THISFORM.grid_web_retetar.RECORDSOURCE
		SELECT (lcTabelCum)
		LOCATE FOR cante > cant_in_stoc
		IF FOUND()
			amessagebox("Exista materii prime pentru care cantitatea care se scade depaseste cantitatea din stoc!",0+48,"Atentie")
			THISFORM.grid_web_reteta.SETFOCUS()
			RETURN .F.
		ENDIF
		
		llSucces = THIS.MAKE_RULTEMP()
		IF !llSucces
			RETURN .F.
		ENDIF
		
		***********************************************************************************************************************8
		*!*	SELECT rul_temp && crsProduseIesiri
		*!*	CALCULATE SUM(ROUND(PRET*cante,gnPc)), SUM(ROUND(cante*(pretv-PRET),gnPc)) TO pnBazaBon, pnAdaos
		
		&& NOTE
		SELECT * FROM XNOTE WHERE id_set = oset.id_set INTO CURSOR crsNota
		
		lcField = ''
		SELECT xact
		GO TOP
		
		FOR i = 1 TO FCOUNT()
			IF UPPER(ALLTRIM(EVALUATE(FIELD(i)))) = 'SUMA'
				lcField = FIELD(i)
				EXIT
			ENDIF
		ENDFOR
		
		IF EMPTY(lcField)
			RETURN .T.
		ENDIF
		
		LOCAL lnValAchizitie, lnValctva
		STORE 0 TO lnValAchizitie, lnValctva
		
		SELECT cweb_vanzari
		CALCULATE SUM(ROUND(pretvtva*cant_vand,gnPC)) ;
			TO lnValctva
		CALCULATE SUM(ROUND(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1), gnPPretV)*cant_vand,gnPC)) ;
			TO pnBazaFactura
		
		SELECT rul_temp
		CALCULATE SUM(ROUND(PRET*cante, gnPC)) TO lnValAchizitie FOR CONT = '301'
		
		pnTVAFactura = lnValctva - pnBazaFactura
		pnAdaosTotal = pnBazaFactura - lnValAchizitie
		
		SELECT actactan
		SCATTER NAME loActactan
		REPLACE ALL suma WITH lnValAchizitie
		REPLACE id_gestin WITH pnIdGest_InProd FOR scd = '345' AND scc = '711'
		REPLACE id_gestin WITH pnIdGest_InMarf, id_gestout WITH pnIdGest_InMarf FOR scd = '371' AND scc = '345'
		REPLACE suma WITH pnAdaosTotal, id_gestin WITH pnIdGest_InMarf, id_gestout WITH pnIdGest_InMarf FOR scd = '371' AND scc = '378'
		REPLACE suma WITH pnAdaosTotal, id_gestout WITH pnIdGest_InMarf FOR scd = '378' AND scc = '371'
		
		REPLACE suma WITH lnValAchizitie, id_gestout WITH pnIdGest_InMarf FOR scd = '607' AND scc = '371'
		
		SELECT DISTINCT acont FROM rul_temp WHERE CONT = '301' INTO CURSOR cAcont301
		SELECT cAcont301
		SCAN
			lnValAchizitie = 0
			lcAcont = acont
			SELECT rul_temp
			CALCULATE SUM(ROUND(PRET*cante, gnPC)) TO lnValAchizitie FOR CONT = '301' AND acont = lcAcont
			SELECT actactan
			LOCATE FOR scc = '301' AND EMPTY(ascc)
			IF FOUND()
				REPLACE suma WITH lnValAchizitie, ascc WITH lcAcont
			ELSE
				SELECT actactan
				LOCATE FOR scc = '301'
				SCATTER NAME lo301
				APPEND BLANK
				GATHER NAME lo301
				REPLACE suma WITH lnValAchizitie, ascc WITH lcAcont
			ENDIF
			SELECT cAcont301
		ENDSCAN
		
		*!*	SELECT cWeb_Vanzari
		*!*	CALCULATE SUM(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1)*cant_vand,gnPc)), ;
		*!*		SUM(ROUND((pretvtva - (pretvtva/IIF(proc_tvav<>0,proc_tvav,1))) * cant_vand,gnPc)) ;
		*!*		TO pnBazaFactura, pnTVAFactura
		
		***------------------
		* 411 = 70x
		SELECT proc_tvav, SUM(ROUND(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1), gnPPretV)*cant_vand,gnPC)) AS bazaFact ;
			FROM cweb_vanzari ;
			GROUP BY proc_tvav ;
			INTO CURSOR cBazaCote
		
		SELECT actactan
		LOCATE FOR LEFT(scd,3) = '411' AND LEFT(scc,1) = '7'
		IF FOUND()
			SCATTER NAME loActBaza
			DELETE
		
			SELECT cBazaCote
			SCAN
				lnProc_tvav = proc_tvav
				lnBazaFact = bazaFact
				SELECT actactan
				loActBaza.proc_tva = lnProc_tvav
				loActBaza.suma = lnBazaFact
				* REPLACE suma WITH pnBazaFactura
				APPEND BLANK
				GATHER NAME loActBaza
				SELECT cBazaCote
			ENDSCAN
		
			IF USED("cBazaCote")
				USE IN cBazaCote
			ENDIF
			RELEASE loActBaza
		ENDIF
		
		***------------------
		
		*!*	SELECT actactan
		*!*	LOCATE FOR LEFT(scd,3) = '411' AND LEFT(scc,1) = '7'
		*!*	IF FOUND()
		*!*		REPLACE suma WITH pnBazaFactura
		*!*	ENDIF
		
		***------------------
		* 411 = 4427
		
		SELECT proc_tvav, SUM(ROUND(pretvtva*cant_vand,gnPC)) - SUM(ROUND(ROUND(pretvtva/IIF(proc_tvav<>0,proc_tvav,1), gnPPretV)*cant_vand,gnPC)) AS TVAFact ;
			FROM cweb_vanzari ;
			GROUP BY proc_tvav ;
			INTO CURSOR cTVACote
		
		SELECT actactan
		LOCATE FOR LEFT(scd,3) = '411' AND ALLTRIM(scc) = '4427'
		IF FOUND()
			SCATTER NAME loActTVA
			DELETE
		
			SELECT cTVACote
			SCAN
				lnProc_tvav = proc_tvav
				lnTVAFact = TVAFact
				SELECT actactan
				loActTVA.proc_tva = lnProc_tvav
				loActTVA.suma = lnTVAFact
		
				APPEND BLANK
				GATHER NAME loActTVA
				SELECT cTVACote
			ENDSCAN
		
			IF USED("cTVACote")
				USE IN cTVACote
			ENDIF
			RELEASE loActTVA
		ENDIF
		
		
		***------------------
		
		*!*	SELECT actactan
		*!*	LOCATE FOR LEFT(scd,3) = '411' AND ALLTRIM(scc) = '4427'
		*!*	IF FOUND()
		*!*		REPLACE suma WITH pnTVAFactura
		*!*	ENDIF
		
		SELECT actactan
		LOCATE FOR LEFT(scd,1) = '5' AND LEFT(scc,3) = '411'
		IF FOUND()
			REPLACE suma WITH lnValctva
		ENDIF
		***------------------
		IF USED("cAcont301")
			USE IN cAcont301
		ENDIF
		
		***----------------------------------------------------------------------------------------------
		SELECT rul_temp
		REPLACE ALL dataact WITH loActactan.dataact, ;
			nnir WITH loActactan.nnir, ;
			id_sectie WITH loActactan.id_sectie, ;
			id_responsabil WITH loActactan.id_responsabil, ;
			id_lucrare WITH loActactan.id_lucrare
		IF USED('crsNota')
			USE IN crsNota
		ENDIF
		
		&& ordonez notele contabile in ACTACTAN
		SELECT actactan
		SUM suma TO lnSume
		
		IF lnSume <> 0
			lcCondDele = [!(suma = 0 and !(((left(scd,1) = '3' and left(scc,2) = '40') OR (left(scd,2) = '41' and left(scc,1) = '7')) AND proc_tva # 1))]
		ELSE
			lcCondDele = [suma = 0 AND nr_nota = 1 ]
		ENDIF
		
		SELECT * FROM actactan INTO CURSOR crsActActan WHERE &lcCondDele OR INLIST(id_set, 89, 210, 211, 212) ORDER BY nr_nota NOFILTER READWRITE
		
		SELECT actactan
		DELETE FROM actactan
		APPEND FROM DBF('crsactactan')
		IF USED('crsactactan')
			USE IN crsActActan
		ENDIF
		
		&& completare analitice
		SELECT actactan
		SCAN FOR EMPTY(NVL(ascd,''))
			SCATTER NAME loActactan
			IF TYPE('loActactan.cont') = 'U'
				x = ADDPROPERTY(loActactan,'cont',loActactan.scd)
			ENDIF
			IF oset.model = 2 AND TYPE('loActactan.id_gestiune') = 'U'              && NIR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestin)
			ENDIF
			IF INLIST(oset.model, 3, 4) AND TYPE('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestout)
			ENDIF
			loActactan.ascd = THIS.assign_analitic(loActactan.scd,THIS.cobj,'loActactan')
			REPLACE ascd WITH loActactan.ascd
			SELECT actactan
		ENDSCAN
		
		SELECT actactan
		SCAN FOR EMPTY(NVL(ascc,''))
			SCATTER NAME loActactan
			IF TYPE('loActactan.cont') = 'U'
				x = ADDPROPERTY(loActactan,'cont',loActactan.scc)
			ENDIF
			IF oset.model = 2 AND TYPE('loActactan.id_gestiune') = 'U'              && NIR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestin)
			ENDIF
			IF INLIST(oset.model, 3, 4) AND TYPE('loActactan.id_gestiune') = 'U'    && BON, RETUR
				x = ADDPROPERTY(loActactan,'id_gestiune',loActactan.id_gestout)
			ENDIF
			loActactan.ascc = THIS.assign_analitic(loActactan.scc,THIS.cobj,'loActactan')
			REPLACE ascc WITH loActactan.ascc
			SELECT actactan
		ENDSCAN
		
		SELECT actactan
		LOCATE FOR scd = '371' AND scc = '345'
		IF FOUND()
			lcAscd = ascd
			SELECT rul_temp
			REPLACE ALL acont WITH lcAscd FOR CONT = '371' AND cante <> 0 AND cant = 0
		ENDIF
		
		SELECT actactan
		LOCATE FOR scd = '371' AND scc = '378'
		IF FOUND()
			lcAscd = ascd
			SELECT rul_temp
			REPLACE ALL acont WITH lcAscd FOR CONT = '371' AND cante = 0 AND cant <> 0
			SELECT actactan
			REPLACE id_gestout WITH 0 FOR scd = '371' AND scc = '378'
		ENDIF
		
		SELECT actactan
		REPLACE id_gestin WITH pnIdGest_InMarf, id_gestout WITH pnIdGest_InProd FOR scd = '371' AND scc = '345'
		
		IF TYPE('loActactan') = 'O'
			RELEASE loActactan
		ENDIF
		
		SELECT actactan
		GO TOP
		
		RETURN .T.
		
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		SELECT * FROM XNOTE WHERE id_set = oset.id_set INTO CURSOR crsNota
		SELECT crsNota
		LOCATE FOR XSCD = '4428'
		IF FOUND()
			thisform.lPretVanz = .T.
		ENDIF 
	ENDPROC

	PROCEDURE make_rultemp
		&& completez RUL_TEMP
		
		lcProduse = THIS.grid_web.RECORDSOURCE
		lcMateriale = THIS.grid_web_retetar.RECORDSOURCE
		
		*!*CREATE TABLE c:\test.dbf (produs c(100), id_produs n(10), material C(100), id_mat n(10), cant_nec n(18,5), pret n(18,5), cante n(18,5), cantramas n(18,5), stoc n(18,5))
		
		IF USED('rul_temp')
			USE IN rul_temp
		ENDIF
		
		* lcRul = ALLTRIM(THIS.osel_dr.cfrom)
		lcSql = [select v.*, v.id_gestiune as id_gestin, v.nume_gestiune as gestin, v.id_gestiune as id_gestout,] + ;
			[v.nume_gestiune as gestout, 0 as nuInConturiX from ] + gcS + [.vrul v where 1=2]
		lcCursor = [rul_temp]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		ENDIF
		
		IF USED("crsStocActual1")
			USE IN crsStocActual1
		ENDIF
		
		*!*	lcSql = [select denumire, id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont, SUM(cants + cant - cante) as stoc from vstoc where an = ] + ;
		*!*		TRANSFORM(gnAn) + [ and luna = ] + TRANSFORM(gnLuna) + [ and id_gestiune in (] + TRANSFORM(poAct.id_gestiune)+ [)] + ;
		*!*		[ group by denumire, id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont order by pret]
		lcSql = [select id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont, SUM(cants + cant - cante) as stoc ] + ;
			[from stoc where an = ] + TRANSFORM(gnAn) + [ and luna = ] + TRANSFORM(gnLuna) + ;
			[ and id_gestiune in (] + TRANSFORM(poAct.id_gestiune)+ [) and id_rul_aux is null ] + gcCondSucursala + ;
			[ group by id_articol, id_gestiune, pret, tva, proc_tvav, cont, acont order by pret]
		lcCursor = [crsStocActual1]
		lnSucces = goExecutor.oExecute(lcSql,lcCursor)
		IF lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare,0+16, 'Eroare')
		ENDIF
		
		IF USED("crsStocActual")
			USE IN crsStocActual
		ENDIF
		
		SELECT * FROM crsStocActual1 ;
			WITH (BUFFERING = .T.) ;
			INTO CURSOR crsStocActual ;
			READWRITE
			
		
		*!*SELECT * FROM crsStocActual INTO TABLE c:\ccrsStocActual.dbf 	
		
		SELECT * FROM crsStocActual1 ;
			WITH (BUFFERING = .T.) ;
			INTO CURSOR crsStocActual_2 ;
			READWRITE
			
		*!*SELECT * FROM crsStocActual_2 INTO TABLE c:\ccrsStocActual_2.dbf	
		
		IF USED("crsStocActual1")
			USE IN crsStocActual1
		ENDIF
		
		****************
		IF USED("crsMateriale")
			USE IN crsMateriale
		ENDIF
		
		*!*	SELECT id_material AS id_articol, IIF(cant_nec < cant_in_stoc, cant_nec, cant_in_stoc) AS cante ;
		*!*		FROM (lcMateriale) ;
		*!*		WITH (buffering = .t.) ;
		*!*		INTO CURSOR crsMateriale ;
		*!*		READWRITE
		
		
		
		SELECT id_material AS id_articol, cante ;
			FROM (lcMateriale) ;
			WITH (BUFFERING = .T.) ;
			INTO CURSOR crsMateriale ;
			READWRITE
		
		SELECT crsMateriale
		SCAN FOR cante > 0
			lnCantRamas = cante
			lnIdArticol = id_articol
			lnCantInit = cante
		*!*		lcMaterial = ALLTRIM(denumire)
			SELECT crsStocActual
			LOCATE FOR id_articol = lnIdArticol AND stoc > 0 AND lnCantRamas > 0
			DO WHILE FOUND()
				lcCont = CONT
				lcAcont = NVL(acont,'')
		
				lnCante = MIN(lnCantRamas, stoc)
				lnCantRamas = lnCantRamas - lnCante
				lnPret = PRET
				lnIdGestiune = id_gestiune
				
		*!*		INSERT INTO test (material, id_mat, cant_nec, cante, cantramas, stoc, pret) VALUES (lcMaterial, lnIdArticol, lnCantInit, lnCante, lnCantRamas, crsStocActual.stoc, lnPret)
				REPLACE stoc WITH stoc - lnCante
		
			
				IF LEFT(lcCont,3) <> '371'
					SELECT rul_temp
					SCATTER NAME loRul BLANK
					WITH loRul
						.id_articol = lnIdArticol
						*.id_gestout = lnIdGestiune
						.id_gestiune = lnIdGestiune
						.cante = lnCante
						.PRET = ROUND(lnPret, gnPpret)
						.CONT = lcCont
						.acont = lcAcont
					ENDWITH
					SELECT rul_temp
					APPEND BLANK
					GATHER NAME loRul
				ENDIF
		
				SELECT crsStocActual
				LOCATE FOR id_articol = lnIdArticol AND stoc > 0 AND lnCantRamas > 0
			ENDDO
			SELECT crsMateriale
		ENDSCAN
		
		IF USED("crsMateriale")
			USE IN crsMateriale
		ENDIF
		***---------------
		* 345 = 711 - intrare produs la pret de achizitie materiale componente
		*!*	SELECT denumire, id_articol, cant_vand AS cant, pretvtva, PRET, proc_tvav, ;
		*!*		0 as nuProdus ;
		*!*		FROM (lcProduse) ;
		*!*		WITH (BUFFERING = .T.) ;
		*!*		INTO CURSOR crsProduseIesiri ;
		*!*		READWRITE
			&& nuProdus ex.: chifle, banane - pe care le cumpara direct ca marfa, si nu devine produs
		
		SELECT id_articol, cant_vand AS cant, pretvtva, PRET, proc_tvav, ;
			0 as nuProdus ;
			FROM (lcProduse) ;
			WITH (BUFFERING = .T.) ;
			INTO CURSOR crsProduseIesiri ;
			READWRITE	
			
		SELECT crsProduseIesiri
		SCAN FOR cant <> 0
			SCATTER NAME loProdus
		*!*			lcProdus = ALLTRIM(denumire)
			lnIdArticol = id_articol
			lnPretvtva = pretvtva
			lnCant = cant
			SELECT * FROM cReteta ;
				WHERE id_produs = lnIdArticol AND pretvtva = lnPretvtva;
				INTO CURSOR cCalcReteta
		
			lnPretCalc = 0
			lnComponente = 0
			lnComponenteGasite = 0
			SELECT cCalcReteta
			SCAN
				lnComponente = lnComponente + 1
				lnCantRamas = cante
				lnId_material = id_material
				lnCantInit = cante
				SELECT crsStocActual_2
				LOCATE FOR id_articol = lnId_material AND stoc > 0 AND lnCantRamas > 0
				DO WHILE FOUND()
					IF LEFT(cont,3) = '371'
						lnComponenteGasite = lnComponenteGasite + 1 
					ENDIF 
					lnCante = MIN(lnCantRamas, stoc)
					lnCantRamas = lnCantRamas - lnCante
					lnPret = PRET
		*!*				lcmaterial = ALLTRIM(denumire)
		*!*			INSERT INTO test (produs, id_produs, material, id_mat, cant_nec, cante, cantramas, stoc, pret) VALUES (lcprodus, lnIdArticol, lcmaterial, lnId_material, lnCantInit, lnCante, lnCantRamas, crsStocActual_2.stoc, lnPret)
					REPLACE stoc WITH stoc - lnCante
		
					lnPretCalc = ROUND(lnPretCalc + ROUND(lnCante * lnPret, gnPpret), gnPpret)
		
					SELECT crsStocActual_2
					LOCATE FOR id_articol = lnId_material AND stoc > 0 AND lnCantRamas > 0
				ENDDO
		
				SELECT cCalcReteta
			ENDSCAN
		
			IF USED("cCalcReteta")
				USE IN cCalcReteta
			ENDIF
			
			IF lnComponenteGasite < lnComponente
			&& daca toate componentele sunt in stoc pe contul 371, nu mai scriu in rul_temp
				SELECT rul_temp
				APPEND BLANK
				GATHER NAME loProdus
				REPLACE PRET WITH ROUND(lnPretCalc/lnCant, gnPpret), CONT WITH '345', id_gestiune WITH pnIdGest_InProd
			ELSE
				SELECT crsProduseIesiri
				REPLACE nuProdus WITH 1
			ENDIF 
		
			SELECT crsProduseIesiri
			REPLACE PRET WITH ROUND(lnPretCalc/lnCant, gnPpret)
		
			SELECT crsProduseIesiri
		ENDSCAN
		
		***--------------
		* 371 = 345 - iesire produs
		SELECT crsProduseIesiri
		SCAN FOR nuProdus = 0
			SCATTER NAME loProdus
			
			SELECT rul_temp
			APPEND BLANK
			GATHER NAME loProdus
			REPLACE cante WITH ROUND(loProdus.cant,gnPCant), ;
				cant WITH 0, ;
				CONT WITH '345', ;
				id_gestiune WITH pnIdGest_InProd 
		
			SELECT rul_temp
			APPEND BLANK
			GATHER NAME loProdus
			REPLACE CONT WITH '371', ;
				id_gestiune WITH pnIdGest_InMarf, ;
				pretv WITH ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPpretV), ;
				adaos WITH ROUND(ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPpretV)-PRET,max(gnPPretV,gnPpret)), ;
				adaos_tva WITH ROUND(ROUND(ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPpretV)-PRET,max(gnPpretV,gnPPret))*IIF(proc_tvav <> 0, proc_tvav-1,0),max(gnPpret,gnPPretV)), ;
				tvav WITH ROUND(pretvtva - ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPpretV),gnPpretV)
				SELECT crsStocActual
		ENDSCAN
		
		***--------------
		* 607 = 371 - iesire marfa
		* SELECT * FROM crsProduseIesiri INTO TABLE c:\crsProduseIesiri.DBF
		
		SELECT crsProduseIesiri
		CALCULATE SUM(ROUND((ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPPretV)-PRET)*cant, gnPC)) TO pnAdaosTotal
		
		SELECT crsProduseIesiri
		SCAN
			SCATTER NAME loProdus
		
			* lnPretv =  ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1),gnPC)
		
			SELECT rul_temp
			APPEND BLANK
			GATHER NAME loProdus
			REPLACE cante WITH ROUND(loProdus.cant,gnPCant), ;
				cant WITH 0, ;
				CONT WITH '371', ;
				id_gestiune WITH pnIdGest_InMarf, ;
				pretv WITH ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPPretV), ;
				adaos WITH ROUND(ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPPretV)-PRET,max(gnPPretV,gnPPret)), ;
				adaos_tva WITH ROUND(ROUND(ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPPretV)-PRET,max(gnPPretV,gnPPret))*IIF(proc_tvav <> 0, proc_tvav-1,0),max(gnPPretV,gnPPret)), ;
				tvav WITH ROUND(pretvtva - ROUND(pretvtva / IIF(proc_tvav <> 0, proc_tvav, 1), gnPPretV),gnPPretV)
		
			SELECT crsStocActual
		ENDSCAN
		
		SELECT crsProduseIesiri
		*!*COPY TO c:\ProduseIesiri
		
		
		
	ENDPROC

	PROCEDURE Release
		* lcSelRul = this.ct_grid_order1.cnumecursor 
		* lcSelSt = this.ct_grid_search1.cnumecursor 
		*!*	IF USED(lcSelRul)
		*!*		USE IN (lcSelRul)
		*!*	ENDIF 
		*!*	IF USED(lcSelSt)
		*!*		USE IN (lcSelSt)
		*!*	ENDIF 
		*!*	IF USED('crsTransfer')
		*!*		USE IN crsTransfer
		*!*	ENDIF 
		
		IF USED("cWeb_vanzari")
			USE IN cWeb_vanzari
		ENDIF 
		
		IF USED("cWeb_vanzari_retetar_o")
			USE IN cWeb_vanzari_retetar_o
		ENDIF 
		
		IF USED("cWeb_vanzari_retetar")
			USE IN cWeb_vanzari_retetar
		ENDIF 
		
		IF USED("cReteta")
			USE IN cReteta
		ENDIF 
		
	ENDPROC

	PROCEDURE cboListe.Valid
		pnId_lista = cListePret.id_pol
		
	ENDPROC

	PROCEDURE cbo_idGest_inMarf.Valid
		pnIdGest_InMarf = crsGestiuni.id_gestiune
		
	ENDPROC

	PROCEDURE cbo_idGest_inProd.Valid
		pnIdGest_InProd = crsGestiuni.id_gestiune
		
	ENDPROC

	PROCEDURE Command1.Click
		loas = CREATEOBJECT("frm_alege_din_stoc")
		loas.lb_titlu_alb_b121.caption = "STOC"
		SELECT xsets
		LOCATE FOR id_set = 92 && tnIdSet
		SCATTER NAME oSet
		*!*	modificare JC/JV 2007
		IF gnNeplatitoare_tva = 1
			oSet.id_jtax = oSet.id_jtaxn
			oSet.id_jnetax = oSet.id_jtaxn
		ENDIF
		*!*	modificare JC/JV 2007	^
		lFactura = oSet.factura
		lAdaos = oSet.adaos
		lDiscount = oSet.discount
		lcTipFrm = UPPER(oSet.explicatia)
		llGestout = .f.
		
		SELECT selectii
		LOCATE FOR id_sel = oSet.id_selSt
		IF FOUND()
			SCATTER NAME ost MEMO
		ELSE
			amessagebox('NECONFIGURAT!',0+48,'Atentie!')
			RETURN 2 && renunt
		ENDIF
		
		lcSelSt = ALLTRIM(ost.cselect) + [ from ] + gcs + [.] + ALLTRIM(ost.cfrom) + [ where ] + ALLTRIM(ost.filtru)
		lcSchemaSt = ALLTRIM(ost.cschema)
		
		WITH loas.ct_grid_search1
			.cselect = lcSelSt
			.cschema = lcSchemaSt
			.cTitlu_coloane = ALLTRIM(ost.titlu_col)
			.cNume_coloane = ALLTRIM(ost.nume_col)
			.cMask = ALLTRIM(ost.mask_col)
			.cFiltruOriginal = lcFiltruOrig
			.cFiltru = ALLTRIM(ost.filtru)
			.cOrder = ALLTRIM(ost.ordine)
			.cTitlu = ALLTRIM(ost.titlu_grid)
			.cb_tx_gestout.VISIBLE = llGestout
			.but_nou1.VISIBLE = llAdMod
			*	.but_modifica1.VISIBLE = llAdMod
		ENDWITH
		
		loas.SHOW(1)
		
		IF buton = 2
			RETURN
		ENDIF
		
		SELECT cursor_curent1
		IF RECCOUNT() > 0
			SCATTER NAME loArticol
			SELECT cReteta
			LOCATE FOR id_material = loArticol.id_articol
			IF !FOUND()
				APPEND BLANK
				REPLACE id_produs WITH pnId_produs, ;
					id_material WITH loArticol.id_articol, ;
					denumire WITH loArticol.denumire, ;
					cant_nec WITH 0, ;
					cant_in_stoc WITH loArticol.cantitate, ;
					um WITH loArticol.um, ;
					adaugat WITH 1
			ENDIF 
		ENDIF
		
		thisform.grid_web_reteta.Refresh 
		thisform.actualizeaza_grid2()
		
		
	ENDPROC

	PROCEDURE grid_web.AfterRowColChange
		LPARAMETERS nColIndex
		
		LOCAL lcTabel
		STORE '' TO lcTabel
		
		lcTabel = this.RecordSource
		
		SELECT (lcTabel)
		thisform.nIdprodus = id_articol
		lcDenumire = ALLTRIM(denumire)
		thisform.nPretvtva = pretvtva
		
		SELECT cReteta
		SET FILTER TO id_produs = thisform.nIdprodus AND pretvtva = thisform.nPretvtva
		thisform.lb_materiiPrime.Caption = "Materii prime pt.: " + NVL(lcDenumire,'') 
		
		SELECT cReteta
		GO TOP 
		
		thisform.grid_web_reteta.Refresh 
		
	ENDPROC

	PROCEDURE grid_web.Column3.Text1.DblClick
		LOCAL lcTabelProduse, lnId_Produs, lcDenumire_pr  
		STORE '' TO lcTabelProduse, lcDenumire_pr  
		STORE 0 TO lnId_Produs
		
		lcTabelProduse = thisform.grid_web.RecordSource
		SELECT (lcTabelProduse)
		
		lnId_Produs = id_articol
		lcDenumire_pr = ALLTRIM(denumire)
		 
		Private poReteta
		Store '' To poReteta
		
		Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza
		*!*	lcSchema1 = [id_ctr N(5), id_part N(10), nume C(30), nr_ctr N(10), data_ctr D(8), obiect C(200), tip N(1), durata N(3), valftva N(20,4), proc_tva N(5,2), avans N(20,4), proc_avans N(5,2),]+;
		*!*		[val_finant N(20,4), proc_finant N(5,2), dobanda N(20,4), proc_dobanda N(5,2), val_rezid N(20,4), proc_rezid N(5,2), ]+;
		*!*		[rata N(20,4), comision N(20,4), proc_comision N(5,2), proc_asigurare N(5,2), val_asigurare N(20,4), val_ctr N(20,4), id_valuta N(5), nume_val C(4), curs N(10,4), zi_plata N(2), incetat N(1), sters N(1) ]
		
		lcSelect1 = [select id_material, denumire_mat, codmat_mat, um_mat, cont_mat, cant_mat from ] + gcS + [.vgest_retetar ]
		lcOrder1 = []
		lcgroup = []
		lcFiltru1 = [id_produs=] + ALLTRIM(STR(lnId_Produs))
		lcFiltruOriginal = []
		llModParam = .T.
		llAfiseaza = .F.
		
		gencursor('poReteta','crsReteta', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		poReteta.ca_baza1.afisare()
		
		SELECT crsReteta
		lofr = CREATEOBJECT("frm_reteta")
		lofr.lb_titlu_alb_b121.caption = "Reteta pentru: " + lcDenumire_pr 
		lofr.show(1)
		
		IF USED("crsReteta")
			USE IN crsReteta
		ENDIF 
		
		RELEASE poReteta
	ENDPROC

	PROCEDURE grid_web.Init
		this.SetAll("DynamicBackColor","IIF(nuInRetetar = 1, RGB(255,0,0), RGB(255,255,255))", "Column")
		
	ENDPROC

	PROCEDURE grid_web_reteta.AfterRowColChange
		LPARAMETERS nColIndex
		
		LOCAL lcTabel, lcTabelCum, lnId_material 
		STORE '' TO lcTabel, lcTabelCum
		STORE 0 TO lnId_material    
		
		lcTabel = this.RecordSource
		lcTabelCum = thisform.grid_web_retetar.RecordSource 
		SELECT (lctabel)
		lnId_material = id_material
		
		SELECT (lcTabelCum) 
		LOCATE FOR id_material = lnId_material 
		thisform.grid_web_retetar.Refresh
		
		
		
		
		
	ENDPROC

	PROCEDURE grid_web_reteta.Column2.Text1.Valid
		LOCAL lcTabel, lnCant_nec, lnCant_in_stoc
		lcTabel = thisform.grid_web_reteta.RecordSource 
		STORE 0 TO lnCant_vand, lnCant_in_stoc
		
		SELECT (lcTabel)
		lnCant_nec = cant_nec
		lnCant_in_stoc = cant_in_stoc
		IF adaugat = 1
			lnCant_Max = lnCant_in_stoc
		ELSE 
			lnCant_Max = MIN(lnCant_nec, lnCant_in_stoc)
		ENDIF 
		
		SELECT (lcTabel)
		IF adaugat = 1
			REPLACE cante WITH MIN(cant_nec, cant_in_stoc)
		ENDIF 
		
		lnCante = cante
		
		IF lnCante > lnCant_Max 
			WAIT WINDOW 'Nu puteti scoate o cantitate mai mare decat cea aflata in stoc/necesara !' NOWAIT
			lnCante = lnCant_Max 
			REPLACE cante WITH lnCante
		ENDIF
		
		
		
		THISFORM.grid_web_reteta.REFRESH
		thisform.actualizeaza_grid2()
	ENDPROC

	PROCEDURE grid_web_reteta.Column5.Text1.Valid
		LOCAL lcTabel, lnCant_nec, lnCant_in_stoc
		lcTabel = thisform.grid_web_reteta.RecordSource 
		STORE 0 TO lnCant_vand, lnCant_in_stoc
		
		SELECT (lcTabel)
		lnCant_nec = cant_nec
		lnCant_in_stoc = cant_in_stoc
		IF adaugat = 1
			lnCant_Max = lnCant_in_stoc
		ELSE 
			lnCant_Max = MIN(lnCant_nec, lnCant_in_stoc)
		ENDIF 
		lnCante = cante
		
		IF lnCante > lnCant_Max 
			WAIT WINDOW 'Nu puteti scoate o cantitate mai mare decat cea aflata in stoc/necesara !' NOWAIT
			lnCante = lnCant_Max 
			REPLACE cante WITH lnCante
		ENDIF
		
		THISFORM.grid_web_reteta.REFRESH
		thisform.actualizeaza_grid2()
	ENDPROC

	PROCEDURE grid_web_reteta.Init
		this.SetAll("DynamicBackColor","IIF(cant_nec_cum > cant_in_stoc, RGB(255,205,155), IIF(adaugat = 1,RGB(255,255,204), RGB(255,255,255)))", "Column")
		
	ENDPROC

	PROCEDURE grid_web_retetar.Init
		this.SetAll("DynamicBackColor","IIF(cante > cant_in_stoc, RGB(255,113,113),IIF(cant_nec > cant_in_stoc, RGB(255,205,155), IIF(adaugat = 1,RGB(255,255,204), RGB(255,255,255))))", "Column")
		
	ENDPROC

	PROCEDURE Lb_titlu_alb_b121.Init
		IF TYPE('oxset.nume_set') # 'U'
			this.Caption = PROPER(ALLTRIM(oxset.nume_set))
		ENDIF 
	ENDPROC

	PROCEDURE txtDataF.Valid
		pdDataF = this.value 
		
		
	ENDPROC

	PROCEDURE txtDataI.Valid
		pdDataI = this.value 
	ENDPROC

	PROCEDURE _shape1.DblClick
		IF thisform.WindowState = 2
			thisform.WindowState = 0
		ELSE 
			thisform.WindowState = 2 
		ENDIF 
	ENDPROC

ENDDEFINE
