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

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="_grdrow1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNr_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNr_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNume.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNume.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_livrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_livrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAgent.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAgent.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDelegat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDelegat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNrinmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNrinmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cLucrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cLucrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cFacturat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cFacturat._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataora.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataora.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cUtilizator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cUtilizator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cSelectat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cSelectat._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataLivrat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataLivrat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNr_livrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNr_livrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cTip_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cTip_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAdresa_facturare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAdresa_facturare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAdresa_livrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cAdresa_livrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cComanda_externa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cComanda_externa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNumar_contract.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNumar_contract.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cCodFiscal.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cCodFiscal.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cIdPart.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cIdPart.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCantitate.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCantitate.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPret.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPret.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCodmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCodmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNrCrt.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNrCrt.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPret_cu_tva.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPret_cu_tva._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCodBare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cCodBare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPTVA.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cPTVA.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNumeListaPreturi.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNumeListaPreturi.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_total" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_comenzi_elemente" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_copie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_select_adv1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_factura1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_start_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_attach1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_adauga_lucrare
		*m: do_adauga_lucrare_noua
		*m: do_factura
		*m: do_listeaza_disp
		*m: do_relisteaza_disp
		*p: nid_sectie
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		cgridsortlist = _grdrow1
		filtru_pretty = 
		filtru_pretty_ro = 
		filtru_pretty_ro_full = 
		Height = 497
		Name = "ct_comenzi"
		nid_sectie = 0
		Width = 781
		Gridsort1.Name = "Gridsort1"
		_ct_controller_keypress1.Height = 65
		_ct_controller_keypress1.Left = 134
		_ct_controller_keypress1.Name = "_ct_controller_keypress1"
		_ct_controller_keypress1.Top = 67
		_ct_controller_keypress1.Width = 23
	*</PropValue>

	ADD OBJECT '_grdrow1' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 21, ;
		DeleteMark = .F., ;
		Height = 399, ;
		Left = 6, ;
		Name = "_grdrow1", ;
		Panel = 1, ;
		RecordSource = "crscomenzi", ;
		RowHeight = 19, ;
		TabIndex = 15, ;
		Top = 28, ;
		Width = 160, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "nr_comanda", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_comanda", ;
		Column1.ReadOnly = .T., ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "data_comanda", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_comanda", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 83, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "nume", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cNume", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 118, ;
		Column4.ColumnOrder = 10, ;
		Column4.ControlSource = "data_livrare", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Name = "cData_livrare", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 82, ;
		Column5.ColumnOrder = 14, ;
		Column5.ControlSource = "nume_agent", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cAgent", ;
		Column5.ReadOnly = .T., ;
		Column5.Width = 125, ;
		Column6.ColumnOrder = 15, ;
		Column6.ControlSource = "nume_delegat", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cDelegat", ;
		Column6.ReadOnly = .T., ;
		Column7.ColumnOrder = 16, ;
		Column7.ControlSource = "nrinmat", ;
		Column7.FontName = "Arial", ;
		Column7.FontSize = 10, ;
		Column7.Name = "cNrinmat", ;
		Column7.ReadOnly = .T., ;
		Column8.ColumnOrder = 11, ;
		Column8.ControlSource = "nrord", ;
		Column8.FontName = "Arial", ;
		Column8.FontSize = 10, ;
		Column8.Name = "cLucrare", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 92, ;
		Column9.ColumnOrder = 19, ;
		Column9.ControlSource = "facturat", ;
		Column9.FontName = "Arial", ;
		Column9.FontSize = 10, ;
		Column9.Name = "cFacturat", ;
		Column9.ReadOnly = .T., ;
		Column9.Sparse = .F., ;
		Column9.Width = 55, ;
		Column10.ColumnOrder = 20, ;
		Column10.ControlSource = "dataora", ;
		Column10.FontName = "Arial", ;
		Column10.FontSize = 10, ;
		Column10.Name = "cDataora", ;
		Column10.ReadOnly = .T., ;
		Column10.Width = 93, ;
		Column11.ColumnOrder = 21, ;
		Column11.ControlSource = "utilizator", ;
		Column11.FontName = "Arial", ;
		Column11.FontSize = 10, ;
		Column11.Name = "cUtilizator", ;
		Column11.ReadOnly = .T., ;
		Column12.ColumnOrder = 1, ;
		Column12.ControlSource = "selectat", ;
		Column12.FontName = "Arial", ;
		Column12.FontSize = 10, ;
		Column12.Name = "cSelectat", ;
		Column12.Sparse = .F., ;
		Column12.Width = 51, ;
		Column13.ColumnOrder = 13, ;
		Column13.ControlSource = "data_livrat", ;
		Column13.FontName = "Arial", ;
		Column13.FontSize = 10, ;
		Column13.Name = "cDataLivrat", ;
		Column13.ReadOnly = .T., ;
		Column14.ColumnOrder = 12, ;
		Column14.ControlSource = "nr_livrare", ;
		Column14.FontName = "Arial", ;
		Column14.FontSize = 10, ;
		Column14.Name = "cNr_livrare", ;
		Column14.ReadOnly = .T., ;
		Column15.ColumnOrder = 18, ;
		Column15.ControlSource = "tip_comanda", ;
		Column15.FontName = "Arial", ;
		Column15.FontSize = 10, ;
		Column15.Name = "cTip_comanda", ;
		Column16.ColumnOrder = 7, ;
		Column16.ControlSource = "adresa_facturare", ;
		Column16.FontName = "Arial", ;
		Column16.FontSize = 10, ;
		Column16.Name = "cAdresa_facturare", ;
		Column16.Width = 94, ;
		Column17.ColumnOrder = 8, ;
		Column17.ControlSource = "adresa_livrare", ;
		Column17.FontName = "Arial", ;
		Column17.FontSize = 10, ;
		Column17.Name = "cAdresa_livrare", ;
		Column17.Width = 79, ;
		Column18.ColumnOrder = 9, ;
		Column18.ControlSource = "comanda_externa", ;
		Column18.FontName = "Arial", ;
		Column18.FontSize = 10, ;
		Column18.Name = "cComanda_externa", ;
		Column18.Width = 102, ;
		Column19.ColumnOrder = 17, ;
		Column19.ControlSource = "numar_contract", ;
		Column19.FontName = "Arial", ;
		Column19.FontSize = 10, ;
		Column19.Name = "cNumar_contract", ;
		Column19.Width = 88, ;
		Column20.ColumnOrder = 5, ;
		Column20.ControlSource = "cod_fiscal", ;
		Column20.Name = "cCodFiscal", ;
		Column20.ReadOnly = .T., ;
		Column20.Width = 105, ;
		Column21.ColumnOrder = 6, ;
		Column21.ControlSource = "id_part", ;
		Column21.Name = "cIdPart", ;
		Column21.ReadOnly = .T.
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdrow1.cAdresa_facturare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Adresa facturare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cAdresa_facturare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cAdresa_livrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Adresa livrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cAdresa_livrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cAgent.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Agent", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cAgent.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

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

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

	ADD OBJECT '_grdrow1.cComanda_externa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Comanda externa", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cComanda_externa.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cData_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cData_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cData_livrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data livrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cData_livrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cDataLivrat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data livrat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cDataLivrat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cDataora.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data si ora ad.", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cDataora.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cDelegat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Delegat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cDelegat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cFacturat._checkbox1' AS _checkbox WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 40, ;
		Name = "_checkbox1", ;
		ReadOnly = .T., ;
		Top = 47
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT '_grdrow1.cFacturat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Facturata", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cIdPart.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Id partener", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

	ADD OBJECT '_grdrow1.cLucrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Lucrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cLucrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cNr_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNr_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cNr_livrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.livrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNr_livrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cNrinmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Masina", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNrinmat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cNumar_contract.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Numar contract", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNumar_contract.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cNume.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Beneficiar", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNume.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cSelectat._checkbox1' AS _checkbox WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 25, ;
		Name = "_checkbox1", ;
		Top = 35
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT '_grdrow1.cSelectat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Selectat", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cTip_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cTip_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cUtilizator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Utilizator", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cUtilizator.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2' AS _grdrow WITH ;
		Anchor = 13, ;
		ColumnCount = 9, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		Height = 383, ;
		Left = 172, ;
		Name = "_grdrow2", ;
		Panel = 1, ;
		RecordSource = "crscomenzielemente", ;
		RowHeight = 19, ;
		TabIndex = 25, ;
		Top = 44, ;
		Width = 598, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cDenumire", ;
		Column1.Width = 179, ;
		Column2.ColumnOrder = 3, ;
		Column2.ControlSource = "cantitate", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Format = "R", ;
		Column2.InputMask = (get_mask(14,IIF(TYPE("gnPcant")='U',3,gnPcant))), ;
		Column2.Name = "cCantitate", ;
		Column2.Width = 53, ;
		Column3.ColumnOrder = 4, ;
		Column3.ControlSource = "pret", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Format = "R", ;
		Column3.InputMask = (get_mask(14,IIF(TYPE("gnPPretV")='U',2,gnPPretV))), ;
		Column3.Name = "cPret", ;
		Column3.Width = 77, ;
		Column4.ColumnOrder = 6, ;
		Column4.ControlSource = "codmat", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Name = "cCodmat", ;
		Column4.Width = 81, ;
		Column5.ColumnOrder = 1, ;
		Column5.ControlSource = "nrcrt", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cNrCrt", ;
		Column5.Width = 36, ;
		Column6.ColumnOrder = 5, ;
		Column6.ControlSource = "pret_cu_tva", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cPret_cu_tva", ;
		Column6.ReadOnly = .T., ;
		Column6.Sparse = .F., ;
		Column6.Width = 47, ;
		Column7.ControlSource = "codbare", ;
		Column7.FontSize = 10, ;
		Column7.Name = "cCodBare", ;
		Column7.ReadOnly = .T., ;
		Column7.Width = 106, ;
		Column8.ControlSource = "ptva", ;
		Column8.FontSize = 10, ;
		Column8.Name = "cPTVA", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 56, ;
		Column9.ControlSource = "nume_lista_preturi", ;
		Column9.FontSize = 10, ;
		Column9.Name = "cNumeListaPreturi", ;
		Column9.ReadOnly = .T., ;
		Column9.Width = 142
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdrow2.cCantitate.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cCantitate.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cCodBare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod bare", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cCodBare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cCodmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod material", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cCodmat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Articol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cDenumire.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cNrCrt.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.crt.", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cNrCrt.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

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

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

	ADD OBJECT '_grdrow2.cPret.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cPret.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cPret_cu_tva._checkbox1' AS _checkbox WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 27, ;
		Name = "_checkbox1", ;
		ReadOnly = .T., ;
		Top = 31
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT '_grdrow2.cPret_cu_tva.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cu TVA", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

	ADD OBJECT 'But_attach1' AS but_attach WITH ;
		Anchor = 8, ;
		Left = 681, ;
		Name = "But_attach1", ;
		ToolTipText = "Atasare factura la comanda", ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_copie' AS but_grafic WITH ;
		Anchor = 8, ;
		caction = do_copiaza, ;
		cpicturedown = copy_jos.bmp, ;
		cpictureup = copy_sus.bmp, ;
		Left = 589, ;
		Name = "But_copie", ;
		Picture = ..\grafice\copy_sus.bmp, ;
		TabIndex = 18, ;
		ToolTipText = "Copiere comanda (CTRL+C)", ;
		Top = 3, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_factura1' AS but_factura WITH ;
		Anchor = 9, ;
		Left = 739, ;
		Name = "But_factura1", ;
		Top = 3, ;
		Visible = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_listare1' AS but_listare WITH ;
		Anchor = 9, ;
		Left = 710, ;
		Name = "But_listare1", ;
		TabIndex = 24, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_modifica1' AS but_modifica WITH ;
		Anchor = 8, ;
		Left = 619, ;
		Name = "But_modifica1", ;
		TabIndex = 16, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'But_reset_criterii1' AS but_reset_criterii WITH ;
		Anchor = 9, ;
		Left = 498, ;
		Name = "But_reset_criterii1", ;
		Picture = ..\grafice\reset_sus.bmp, ;
		Top = 3, ;
		Visible = .T.
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_start_criterii1' AS but_start_criterii WITH ;
		Anchor = 9, ;
		Comment = "*:OnResize=RT", ;
		Left = 527, ;
		Name = "But_start_criterii1", ;
		Picture = ..\grafice\find_sus.bmp, ;
		Top = 3
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 8, ;
		Left = 649, ;
		Name = "But_sterge1", ;
		TabIndex = 17, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_tx_total' AS clb_tx_simplu WITH ;
		Anchor = 12, ;
		Left = 480, ;
		Name = "Clb_tx_total", ;
		TabIndex = 26, ;
		TabStop = .F., ;
		Top = 434, ;
		Text_simplu1.Alignment = 3, ;
		Text_simplu1.InputMask = (get_mask(14,IIF(TYPE("gnPc")='U',2,gnPc))), ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Text_simplu1.Value = 0, ;
		Lb_simplu1.Caption = "Total comandă", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Cmd_executa1' AS cmd_executa WITH ;
		Anchor = 4, ;
		caction = do_adauga_lucrare, ;
		Caption = "\<Adaugă pe lucrare", ;
		FontBold = .F., ;
		Height = 29, ;
		Left = 119, ;
		Name = "Cmd_executa1", ;
		TabIndex = 20, ;
		Top = 433, ;
		Width = 112, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_executa2' AS cmd_executa WITH ;
		Anchor = 4, ;
		caction = do_relisteaza_disp, ;
		Caption = "\<Relistează dispoziții de livrare", ;
		FontBold = .F., ;
		Height = 29, ;
		Left = 194, ;
		Name = "Cmd_executa2", ;
		TabIndex = 23, ;
		Top = 463, ;
		Width = 186, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_executa3' AS cmd_executa WITH ;
		Anchor = 4, ;
		caction = do_listeaza_disp, ;
		Caption = "\<Listează dispoziții de livrare", ;
		FontBold = .F., ;
		Height = 29, ;
		Left = 7, ;
		Name = "Cmd_executa3", ;
		TabIndex = 22, ;
		Top = 463, ;
		Width = 168, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_executa4' AS cmd_executa WITH ;
		Anchor = 4, ;
		caction = do_adauga_lucrare_noua, ;
		Caption = "Adaugă pe lucrare n\<ouă", ;
		FontBold = .F., ;
		Height = 29, ;
		Left = 233, ;
		Name = "Cmd_executa4", ;
		TabIndex = 21, ;
		Top = 433, ;
		Width = 149, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_select_adv1' AS cmd_select_adv WITH ;
		Anchor = 4, ;
		ccoloana = selectat, ;
		cgrid = this.parent._grdrow1, ;
		FontBold = .F., ;
		ForeColor = 0,64,128, ;
		Height = 29, ;
		Left = 7, ;
		Name = "Cmd_select_adv1", ;
		TabIndex = 19, ;
		Top = 433, ;
		Width = 111, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'lb_comenzi_elemente' AS lb_simplu WITH ;
		Anchor = 9, ;
		Caption = "Elemente comandă", ;
		Height = 18, ;
		Left = 172, ;
		Name = "lb_comenzi_elemente", ;
		TabIndex = 28, ;
		Top = 21, ;
		Width = 114
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />
	
	PROCEDURE actualizeaza_cursoare
		*!*	modificare v 2.0.11 : am adaugat This.nid_sectie si gnId_sectie
		Local llCautare
		llCautare = .F.
		 
		If !Used('crscomenzi') Or gcS!=This.cSchema Or Nvl(gnId_sectie,0)!= This.nid_sectie
			If gcS!=This.cSchema Or Nvl(gnId_sectie,0)!= This.nid_sectie
				llCautare = .T.
			Endif
			This.cSchema=gcS
			This.nid_sectie = Nvl(gnId_sectie,0)
			This.creeaza_cursoare()
		*!*		If llCautare
		*!*			This.do_cauta()
		*!*		Endif
		Endif
	ENDPROC

	PROCEDURE actualizeaza_grid1
		Lparameters tcFiltru
		
		If Empty(tcFiltru)
			lcFiltru=pocomenzi.ca_baza1.cfiltru
		Else
			lcFiltru=tcFiltru
		Endif
		
		This._grdrow1.salveaza_grid()
		If Used('crstempcomenzi')
			Use In crstempcomenzi
		Endif
		Select * From crscomenzi With (Buffering = .T.) Where selectat=1 Into Cursor crstempcomenzi Readwrite
		lnSelectate=Reccount('crstempcomenzi')
		pocomenzi.ca_baza1.cfiltru=lcFiltru
		pocomenzi.ca_baza1.afisare()
		lcOrder=pocomenzi.ca_baza1.corder
		Insert Into crstempcomenzi Select * From crscomenzi Where id_comanda Not In (Select id_comanda From crstempcomenzi)
		Select crstempcomenzi
		If Used('crscomenzi')
			Use In crscomenzi
		Endif
		lcComanda=[Select * From crstempcomenzi order by selectat desc,]+lcOrder+[ Into Cursor crscomenzi readwrite]
		&lcComanda
		*!*	modificare	v 2.0.1
		*!*	This.actualizeaza_selectate(lnSelectate)
		*!*	modificare	v 2.0.1	^
		If Used('crstempcomenzi')
			Use In crstempcomenzi
		Endif
		This._grdrow1.incarca_grid()
		*!*	This._grdrow1.SetAll("DynamicForeColor","IIF(inchisa=1,RGB(128,128,128),RGB(0,0,0))","Column")
		
		* comenzi lucrari inchise: italic
		* comenzi facturate : verde
		* comenzi nefacturate: negru
		This._grdrow1.SetAll("DynamicFontItalic","IIF(inchisa=1,.T.,.F.)","Column")
		THIS._GRdrow1.SetAll("DynamicForeColor", "IIF(facturat = 1, RGB(0,128,128), RGB(0,0,0))","Column")
		
		*!*	modificare	v 2.0.27
		This._grdrow1.cAdresa_facturare.DynamicBackColor = "IIF(afs=1,rgb(255,128,128),iif(afi=1,rgb(225,225,225),rgb(255,255,255)))"
		This._grdrow1.cAdresa_livrare.DynamicBackColor = "IIF(als=1,rgb(255,128,128),iif(ali=1,rgb(225,225,225),rgb(255,255,255)))"
		*!*	modificare	v 2.0.27	^
		If Reccount('crscomenzi')>0
			This.cmd_executa1.Enabled=.T.
			This.cmd_executa3.Enabled=.T.
			This.cmd_select_adv1.Enabled=.T.
		Else
			This.cmd_executa1.Enabled=.F.
			This.cmd_executa3.Enabled=.F.
			This.cmd_select_adv1.Enabled=.F.
		Endif
	ENDPROC

	PROCEDURE actualizeaza_grid2
		Lparameters tcFiltru
		If Empty(tcFiltru)
			lcFiltru=pocomenzielemente.ca_baza1.cfiltru
		Else
			lcFiltru=tcFiltru
		Endif
		
		This._grdrow2.salveaza_grid()
		pocomenzielemente.ca_baza1.cfiltru=lcFiltru
		pocomenzielemente.ca_baza1.afisare()
		*!*	modificare	v 2.0.28
		This._grdrow2.cCantitate.InputMask = get_mask(14,gnPCant)
		This._grdrow2.cPret.InputMask = get_mask(14,gnPPretV)
		This.clb_tx_total.text_simplu1.InputMask = get_mask(14,gnPc)
		*!*	modificare	v 2.0.28	^
		This._grdrow2.incarca_grid()
		
		If Used('crssuma')
			Use In crssuma
		Endif
		Select Nvl(Sum(Round(Pret*cantitate,gnPc)),0) As Total From crscomenzielemente Into Cursor crssuma
		Select crssuma
		This.clb_tx_total.text_simplu1.Value=Total
		If Used('crssuma')
			Use In crssuma
		Endif
		
	ENDPROC

	PROCEDURE creeaza_cursoare
		Local lcSchema,lcSelect,lcOrder,lcFiltru,llAfiseaza
		Store '' To pocomenzi,pocomenzielemente
		This._grdrow1.salveaza_grid()
		This._grdrow2.salveaza_grid()
		*!*	modificare	v 2.0.20 : am adaugat id_ctr, numar_contract
		*!*	modificare	v 2.0.24 : am adaugat id_util_um, dataora_um
		*!*	modificare	v 2.0.27 : am adaugat afs, afi, als, ali
		lcSchema=[selectat n(1),id_comanda n(20),COMANDA_EXTERNA c(20),id_codclient c(20),id_lucrare n(20),id_part n(20),id_gestiune n(20),id_agent n(20),id_delegat n(20),id_masina n(20),]+;
			[nr_comanda c(100),data_comanda t,nume c(100),cod_fiscal C(20),data_livrare t,nume_agent c(70),nume_delegat c(70),]+;
			[serie_bi c(4),numar_bi c(10),eliberatde c(50),nrinmat c(10),nrord c(30),facturat n(1),dataora t,]+;
			[utilizator c(40),data_livrat t,interna n(1),proc_discount n(10,2),]+;
			[nr_livrare c(50),inchisa n(1),tip_comanda c(50),id_sectie n(5),id_sectie2 n(5),id_facturare n(5),]+;
			[id_livrare n(5),adresa_facturare c(50),afs n(1),afi n(1),adresa_livrare c(50),als n(1),ali n(1),cod_client c(50),id_ctr n(10),numar_contract c(100),]+;
			[id_util_um n(10),dataora_um t]
		lcSelect=[select 0 as selectat,a.id_comanda,a.COMANDA_EXTERNA,a.id_codclient,a.id_lucrare,a.id_part,a.id_gestiune,a.id_agent,a.id_delegat,a.id_masina,]+;
			[a.nr_comanda,a.data_comanda,a.nume,a.cod_fiscal,a.data_livrare,a.nume_agent,a.nume_delegat,a.serie_bi,a.numar_bi,a.eliberatde,]+;
			[a.nrinmat,a.nrord,a.facturat,a.dataora,a.utilizator,a.data_livrat,a.interna,a.proc_discount,a.nr_livrare,a.inchisa,] + ;
			[a.tip_comanda,a.id_sectie,a.id_sectie2,a.id_facturare,a.id_livrare,] + ;
			[NVL(b.denumire_adresa, b.adresa) as adresa_facturare,b.sters as afs,b.inactiv as afi,] + ;
			[NVL(c.denumire_adresa, c.adresa) as adresa_livrare,c.sters as als,c.inactiv as ali,] +;
			[d.cod as cod_client,a.id_ctr,a.numar_contract,a.id_util_um,a.dataora_um ] + ;
			[from vcomenzi a left join vadrese_parteneri b on b.id_adresa=a.id_facturare left join vadrese_parteneri c on c.id_adresa=a.id_livrare left join parteneri_coduri d on d.id=a.id_codclient]
		
		lcOrder=[data_comanda] + IIF(TYPE('gnRF_ORDONARECOMENZI') = 'N' AND m.gnRF_ORDONARECOMENZI = 2, " DESC", "") && 1 = ASC, 2 = DESC
		lcFiltru = [id_comanda = -9999999]
		lcFiltruOriginal = [] && [id_sectie =]+ALLTRIM(STR(gnId_sectie))
		llAfiseaza = .F.
		lcgroup = []
		llModParam = .T.
		llAfiseaza = .F.
		*gencursor('pocomenzi','crscomenzi',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza)
		gencursor('pocomenzi','crscomenzi', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		pocomenzi.ca_baza1.afisare()
		
		*!*	modificare v 2.0.8	:	am adaugat pret_cu_tva
		lcSchema=[nrcrt n(20),id_comanda_element n(20),id_comanda n(20),id_articol n(20),id_pol n(20),nume_lista_preturi C(200),denumire c(100),pret n(16,3),cantitate n(16,3),um c(10),codmat c(40),codbare c(50),pret_cu_tva n(1),ptva n(5,2)]
		lcSelect=[select row_number() over (order by id_comanda_element) as nrcrt,id_comanda_element,id_comanda,] + ;
			[id_articol,id_pol,nume_lista_preturi,denumire,pret,cantitate,um,codmat,codbare,pret_cu_tva,ptva from vcomenzi_elemente ]
		lcOrder=[id_comanda_element]
		lcFiltru = [id_comanda = -9999999]
		llAfiseaza = .F.
		*gencursor('pocomenzielemente','crscomenzielemente',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza)
		gencursor('pocomenzielemente','crscomenzielemente', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
		pocomenzielemente.ca_baza1.afisare()
		
		This.clb_tx_total.text_simplu1.Value = 0
		This._grdrow1.incarca_grid()
		This._grdrow2.incarca_grid()
		*!*	modificare v 2.0.11
		*!*	*!*	modificare	v 2.0.1
		*!*	This.do_cauta()
		*!*	*!*	modificare	v 2.0.1	^
		*!*	modificare v 2.0.11	^
	ENDPROC

	PROCEDURE do_adauga
		Private pniesire,pcNrComanda
		Store [] To pcNrComanda
		pniesire=0
		If Used('crscomanda_curenta')
			Use In crscomanda_curenta
		Endif
		Select a.*,Round(a.Pret*a.cantitate,gnPc) As valoare From crscomenzielemente a Where 1=2 Into Cursor crscomanda_curenta Readwrite
		Select crscomenzi
		Scatter Name loRec Blank
		
		goExecutor.oFunction2Value([pack_comenzi.genereaza_nr_comanda],@pcNrComanda)
		loRec.interna = 2
		loRec.nr_comanda=pcNrComanda
		*!*	update_articole_politica_utilizator()
		Do Adauga_Modifica_Inregistrare With "comenzi",loRec,,"INSERT"
		If pniesire=1
			This.actualizeaza_grid1()
			Select crscomenzi
			Locate For data_comanda=loRec.data_comanda And nr_comanda=loRec.nr_comanda
			This.do_modifica(1)
		*!*		This._grdrow1.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_adauga_lucrare
		If Used('crstempcomlucrare')
			Use In crstempcomlucrare
		Endif
		Select * From crscomenzi Where selectat=1 Into Cursor crstempcomlucrare
		If Reccount('crstempcomlucrare')=0
			amessagebox("Selectati cel putin o comanda!",0+48,"Atentie")
			Use In crstempcomlucrare
			Return
		Endif
		
		Select crstempcomlucrare
		Calculate Count() For !Isnull(id_lucrare) To lnNrLucrari
		Calculate Max(data_livrare) To ltMaxDataLivrare
		
		If lnNrLucrari>0
			If amessagebox("Exista comenzi selectate care se afla deja pe lucrari.Doriti sa le mutati pe alta lucrare?",4+48+256,"Atentie")<>6
				Use In crstempcomlucrare
				Return
			Endif
		Endif
		
		Local loCauta
		loCauta=caut_lucrari_curente_gs()
		*!*	Do Case
		*!*	Case (!Isnull(loCauta.termen_executie) Or !Empty(loCauta.termen_executie)) And loCauta.termen_executie<ltMaxDataLivrare
		*!*		aMessagebox("Comanda "+lcComanda+" are termenul de livrare mai mare decat termenul de executie al lucrarii "+loCauta.nrord+" !",0+48,"Atentie")
		*!*	Case !Empty(loCauta.id_lucrare)
		*!*		Select crstempcomlucrare
		*!*		Browse
		*!*	Endif
		If !Empty(loCauta.id_lucrare)
		*!*			Select crstempcomlucrare
		*!*			Scan
		*!*				lnIdComanda=id_comanda
		*!*				lcSql = [begin pack_comenzi.adauga_lucrare_pe_comanda(] + Alltrim(Str(lnIdComanda)) + [,] + ;
		*!*					ALLTRIM(Str(loCauta.id_lucrare)) + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		*!*				lnSucces = goExecutor.oExecute(lcSql)
		
		*!*				If lnSucces < 0
		*!*					amessagebox(goExecutor.cEroare,0+16,"Eroare")
		*!*					Return
		*!*				Endif
		*!*				Update crscomenzi Set id_lucrare=loCauta.id_lucrare,nrord=Alltrim(loCauta.nrord) Where id_comanda=lnIdComanda
		*!*			Endscan
		*!*
		*!*			lcSql = [begin pack_comenzi.actualizeaza_articole_lucrare(] + ALLTRIM(Str(loCauta.id_lucrare)) + [,] + ;
		*!*				Alltrim(Str(gnIdUtil)) + [); end;]
		*!*			lnSucces = goExecutor.oExecute(lcSql)
		
		*!*			If lnSucces < 0
		*!*				amessagebox(goExecutor.cEroare,0+16,"Eroare")
		*!*				Return
		*!*			Endif
		*!*	modificare	v 2.0.9
			If verifica_lucrare(loCauta.id_lucrare,[crstempcomlucrare])
		*!*	modificare	v 2.0.9	^
				MakeTransactable('crscomenzi')
				If IsTransactable('crscomenzi')
		&&	cu tranzactii
					lcSirIdComenzi=[]
					Begin Transaction
					Select crstempcomlucrare
					Scan
						lnIdComanda=id_comanda
						lcSirIdComenzi=lcSirIdComenzi+Alltrim(Str(lnIdComanda))+[;]
						Update crscomenzi Set id_lucrare=loCauta.id_lucrare,nrord=Alltrim(loCauta.nrord) Where id_comanda=lnIdComanda
					Endscan
		
					lcSql = [begin pack_comenzi.adauga_lucrare_pe_comenzi('] + Alltrim(lcSirIdComenzi) + [',] + ;
						ALLTRIM(Str(loCauta.id_lucrare)) + [,] + Alltrim(Str(gnIdUtil)) + [,]+Alltrim(Str(This.nid_sectie))+[); end;]
					lnSucces = goExecutor.oExecute(lcSql)
		
					If lnSucces < 0
						amessagebox(goExecutor.oPrelucrareEroare(),0+16,"Eroare")
						Rollback
					Else
						End Transaction
						amessagebox("Comenzile au fost adaugate pe lucrare!",0+64,"Info actualizare")
					Endif
		
				Else
		&&	fara tranzactii
					Select crstempcomlucrare
					Scan
						lnIdComanda=id_comanda
						lcSirIdComenzi=lcSirIdComenzi+Alltrim(Str(lnIdComanda))+[;]
						Update crscomenzi Set id_lucrare=loCauta.id_lucrare,nrord=Alltrim(loCauta.nrord) Where id_comanda=lnIdComanda
					Endscan
		
					lcSql = [begin pack_comenzi.adauga_lucrare_pe_comenzi('] + Alltrim(Str(lcSirIdComenzi)) + [',] + ;
						ALLTRIM(Str(loCauta.id_lucrare)) + [,] + Alltrim(Str(gnIdUtil)) + [,]+Alltrim(Str(This.nid_sectie))+[); end;]
					lnSucces = goExecutor.oExecute(lcSql)
		
					If lnSucces < 0
						amessagebox(goExecutor.oPrelucrareEroare(),0+16,"Eroare")
					Else
						Select crstempcomlucrare
						Scan
							lnIdComanda=id_comanda
							Update crscomenzi Set id_lucrare=loCauta.id_lucrare,nrord=Alltrim(loCauta.nrord) Where id_comanda=lnIdComanda
						Endscan
						amessagebox("Comenzile au fost adaugate pe lucrare!",0+64,"Info actualizare")
					Endif
				Endif
		*!*		this.actualizeaza_grid1()
		*!*	modificare	v 2.0.9
			Endif
		*!*	modificare	v 2.0.9	^
		Endif
		
		Use In crstempcomlucrare
	ENDPROC

	PROCEDURE do_adauga_lucrare_noua
		Private pnIdLucrare,pcNrOrd,ptDataLucrare
		Store 0 To pnIdLucrare
		Store "" To pcNrOrd
		If Used('crstempcomlucrare')
			Use In crstempcomlucrare
		Endif
		Select * From crscomenzi Where selectat=1 Into Cursor crstempcomlucrare
		If Reccount('crstempcomlucrare')=0
			amessagebox("Selectati cel putin o comanda!",0+48,"Atentie")
			Use In crstempcomlucrare
			Return
		Endif
		
		Select crstempcomlucrare
		Calculate Count() For !Isnull(id_lucrare) To lnNrLucrari
		Calculate Max(data_livrare) To ltMaxDataLivrare
		
		If lnNrLucrari>0
			If amessagebox("Exista comenzi selectate care se afla deja pe lucrari.Doriti sa le mutati pe alta lucrare?",4+48+256,"Atentie")<>6
				Use In crstempcomlucrare
				Return
			Endif
		Endif
		
		
		*!*	modificare	v 2.0.9
		If verifica_lucrare(NULL,[crstempcomlucrare])
		*!*	modificare	v 2.0.9	^
			ptDataLucrare = get_ora()
			ofrmData = Createobject("frm_data")
			ofrmData.txt_data.ControlSource = 'ptDataLucrare'
			ofrmData.Show(1)
			If gnButon = 1
				lcSql = [begin pack_comenzi.genereaza_lucrare(?ptDataLucrare,?Nvl(gnOre_executie,1),?gnIdUtil,] + ALLTRIM(STR(This.nid_sectie)) + [,?@pcNrOrd,?@pnIdLucrare); end;]
				lnSucces = goExecutor.oExecute(lcSql)
				If lnSucces < 0
					amessagebox(goExecutor.oPrelucrareEroare(),16,"Eroare")
				Else
					MakeTransactable('crscomenzi')
					If IsTransactable('crscomenzi')
		&&	cu tranzactii
						lcSirIdComenzi=[]
						Begin Transaction
						Select crstempcomlucrare
						Scan
							lnIdComanda=id_comanda
							lcSirIdComenzi=lcSirIdComenzi+Alltrim(Str(lnIdComanda))+[;]
							Update crscomenzi Set id_lucrare=pnIdLucrare,nrord=Alltrim(pcNrOrd) Where id_comanda=lnIdComanda
						Endscan
		
						lcSql = [begin pack_comenzi.adauga_lucrare_pe_comenzi('] + Alltrim(lcSirIdComenzi) + [',] + ;
							ALLTRIM(Str(pnIdLucrare)) + [,] + Alltrim(Str(gnIdUtil)) + [,]+Alltrim(Str(This.nid_sectie))+[); end;]
						lnSucces = goExecutor.oExecute(lcSql)
		
						If lnSucces < 0
							amessagebox(goExecutor.oPrelucrareEroare(),0+16,"Eroare")
							Rollback
						Else
							End Transaction
							amessagebox("Comenzile au fost adaugate pe lucrare!",0+64,"Info actualizare")
						Endif
		
					Else
		&&	fara tranzactii
						Select crstempcomlucrare
						Scan
							lnIdComanda=id_comanda
							lcSirIdComenzi=lcSirIdComenzi+Alltrim(Str(lnIdComanda))+[;]
							Update crscomenzi Set id_lucrare=pnIdLucrare,nrord=Alltrim(pcNrOrd) Where id_comanda=lnIdComanda
						Endscan
		
						lcSql = [begin pack_comenzi.adauga_lucrare_pe_comenzi('] + Alltrim(Str(lcSirIdComenzi)) + [',] + ;
							ALLTRIM(Str(pnIdLucrare)) + [,] + Alltrim(Str(gnIdUtil)) + [,]+Alltrim(Str(This.nid_sectie))+[); end;]
						lnSucces = goExecutor.oExecute(lcSql)
		
						If lnSucces < 0
							amessagebox(goExecutor.oPrelucrareEroare(),0+16,"Eroare")
						Else
							Select crstempcomlucrare
							Scan
								lnIdComanda=id_comanda
								Update crscomenzi Set id_lucrare=pnIdLucrare,nrord=Alltrim(pcNrOrd) Where id_comanda=lnIdComanda
							Endscan
							amessagebox("Comenzile au fost adaugate pe lucrare!",0+64,"Info actualizare")
						Endif
					Endif
		*!*		this.actualizeaza_grid1()
				Endif
			Endif
		*!*	modificare	v 2.0.9
		Endif
		*!*	modificare	v 2.0.9	^
		
		Use In crstempcomlucrare
		Release pnIdLucrare,pcNrOrd
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		lcFiltru = [id_sectie = ] + Alltrim(Str(This.nid_sectie))
		
		IF LEN(THIS.filtru_pretty)>0     
			lcFiltru = m.lcFiltru+" and (" + ALLTRIM(THIS.filtru_pretty) + ")"    
		ENDIF
		
		*!*	IF ![inchisa]$m.lcFiltru
		*!*		lcFiltru = lcFiltru + [ and inchisa = 0]
		*!*	ENDIF 
		
		This.actualizeaza_grid1(m.lcFiltru)
		
		If Reccount('crscomenzi')>0
			This._grdrow1.SetFocus()
		Else
			If Reccount('crscomenzielemente')>0
				This.actualizeaza_grid2([1=2])
			ENDIF
			IF this.lShowRezultate
				amessagebox("Cautarea nu a intors rezultate!",0+64,"Info cautare")
			ENDIF 	
		Endif
		
		
	ENDPROC

	PROCEDURE do_copiaza
		If Reccount('crscomenzi') > 0
			Private pnId_comanda, pnId_comanda_nou, pcSir, pcSeparator
			Store 0 To pnId_comanda, pnId_comanda_nou
			Store "" To pcSir,pcSeparator
		
			If Used('crscopycom')
				Use In crscopycom
			Endif
			Select * From crscomenzi Where selectat=1 Into Cursor crscopycom Readwrite
			Do Case
				Case Reccount('crscopycom')=0
					amessagebox("Selectati cel putin o comanda!",0+48,"Atentie")
					Use In crscopycom
					Return
				Case Reccount('crscopycom')=1
					Select crscopycom
					pnId_comanda = id_comanda
					lnNr_comanda = Alltrim(nr_comanda)
					lcData_comanda = Dtoc(Ttod(data_comanda))
		
					lnRaspuns = amessagebox('Doriti sa copiati comanda nr: ' + lnNr_comanda + ' din data ' + lcData_comanda +' ?',4+32,"Confirmare copiere")
					If lnRaspuns = 7
						Use In crscopycom
						Return
					Endif
		
					lcSql = [begin pack_comenzi.copiaza_comanda(?pnId_comanda, NULL, ?gnIdUtil, ?@pnId_comanda_nou); end;]
				Otherwise
					lnRaspuns = amessagebox('Doriti sa copiati comenzile selectate pentru data de azi?',4+32,"Confirmare copiere")
					If lnRaspuns = 7
						Use In crscopycom
						Return
					Endif
		
					pcSeparator = [|]
					Select crscopycom
					Scan
						pcSir = pcSir + Alltrim(Str(id_comanda)) + pcSeparator
					Endscan
		
					lcSql = [begin pack_comenzi.copiaza_comenzi(?pcSir,?pcSeparator,?gnIdUtil); end;]
			Endcase
		
			lnSucces = goExecutor.oExecute(lcSql)
			If lnSucces < 0
				amessagebox(goExecutor.oPrelucrareEroare(),0+16,"Eroare")
			Else
				This.actualizeaza_grid1()
				If pnId_comanda_nou <> 0
					This.Refresh()
					Select crscomenzi
					Locate For id_comanda = pnId_comanda_nou
					If Found()
						*!*	modificare v 2.0.8
						This.actualizeaza_grid2([id_comanda=]+Alltrim(Str(pnId_comanda_nou)))
						*!*	modificare v 2.0.8	^
						This.inainte_de_do_modifica()
					Endif
				Endif
			Endif
			Use In crscopycom
		Else
			amessagebox("Nu exista inregistrari in vizualizare!",0+48,"Atentie")
		Endif
		
	ENDPROC

	PROCEDURE do_factura
		LOCAL lnRec
		SELECT crsComenzi
		SCATTER NAME goComanda MEMO
		lnRec = RECNO() 
		
		DO facturare_comenzi IN oproceduri_facturare.prg
		
		this.do_cauta()
		
		SELECT crsComenzi
		TRY 
			GOTO m.lnRec
		CATCH 
			GO TOP 
		ENDTRY 
	ENDPROC

	PROCEDURE do_listare
		LOCAL lnOptiune, lnRecno
		If Reccount("crscomenzi")>0
			lnRecno = RECNO('crsComenzi')
			*!*		Private pcDataOra	&&	modificare	v 2.0.11
			lnOptiune = xmenu('\<Centralizator comenzi;\<Detalii comanda;\<Detalii comanda (ingust)')
			Do Case
				Case m.lnOptiune = 1
					*!*	modificare	v 2.0.11
					*!*			pcDataOra = get_ora(2)
					*!*	*!*			This.AlwaysOnTop=.F.
					*!*			Select crscomenzi
					*!*			Keyboard "{CTRL+F10}"
					*!*			Report Form centralizator_comenzi To Printer Prompt Preview
					*!*	*!*			This.AlwaysOnTop=.T.
					goExport.export2frx([crscomenzi],[centralizator_comenzi], , , , , , .T.)
					*!*	modificare	v 2.0.11	^
				Case INLIST(m.lnOptiune,2,3)
					If Reccount('crscomenzielemente')=0
						amessagebox("Nu exista elemente pe aceasta comanda!",0+48,"Atentie")
						Return
					Endif
					*!*			pcDataOra = get_ora(2)	&&	modificare v 2.0.11
					Select crscomenzi
					Scatter Name ocomanda
					*!*	*!*			This.AlwaysOnTop=.F.
					*!*	modificare v 2.0.8
					AddProperty(ocomanda,'detalii_adresa_livrare',[])
					AddProperty(ocomanda,'explicatie_tva',[])
					If !Empty(Nvl(ocomanda.id_livrare,0))
						lcCursor = [crsadresalivrare]
						If Used(lcCursor)
							Use In (lcCursor)
						Endif
						lcSql = [select adresa from vadrese_parteneri ] + ;
							[where id_adresa = ] + Alltrim(Str(ocomanda.id_livrare))
						lnSucces = goExecutor.oExecute(lcSql,lcCursor)
						If lnSucces < 0
							amessagebox(goExecutor.cEroare,16,"Eroare")
						Else
							If Reccount(lcCursor)>0
								Select (lcCursor)
								ocomanda.detalii_adresa_livrare = Alltrim(adresa)
							Endif
							If Used(lcCursor)
								Use In (lcCursor)
							Endif
						Endif
					Endif
		
					Use In (SELECT('crsp'))
		
					Select Distinct pret_cu_tva From crscomenzielemente Into Cursor crsp
					If Reccount('crsp')	= 1
						Select crsp
						ocomanda.explicatie_tva = Iif(pret_cu_tva=0,[fără TVA],[cu TVA])
					Endif
					Use In crsp
		
					lcRaport = IIF(m.lnOptiune = 2, [detalii_comanda], [detalii_comanda_ingust])
					goExport.export2frx([crscomenzielemente], m.lcRaport, , , , , , .T.)
		
					Release ocomanda
		
				Otherwise
					Return
			Endcase
		
			SELECT crsComenzi
			TRY 
				GOTO m.lnRecno
			CATCH 
				GO TOP 
			ENDTRY 	
		Else
			amessagebox("Nu exista inregistrari in selectie!",0+48,"Atentie")
		ENDIF
		this._grdrow1.SetFocus()
		
	ENDPROC

	PROCEDURE do_listeaza_disp
		Private pniesire,podetlivrare
		pniesire=0
		If Used('crstempcomlivrare')
			Use In crstempcomlivrare
		Endif
		Select * From crscomenzi Where selectat=1 Into Cursor crstempcomlivrare Readwrite
		If Reccount('crstempcomlivrare')=0
			amessagebox("Selectati cel putin o comanda!",0+48,"Atentie")
			Use In crstempcomlivrare
			Return
		Endif
		
		Select crstempcomlivrare
		Calculate Count() For !Isnull(id_agent) Or !Isnull(id_delegat) Or !Isnull(id_masina) To lnNrAgenti
		Calculate Max(data_livrare),Max(data_comanda) To ltMaxDataLivrare,ltMaxDataComanda
		Calculate Count() For interna=1 To lnComenziInterne
		
		Do Case
		Case lnComenziInterne=Reccount('crstempcomlivrare')
			amessagebox("Pentru comenzile interne nu se pot lista dispozitii!",0+48,"Atentie")
			Use In crstempcomlivrare
			Return
		Case lnComenziInterne>0
			amessagebox("Ati selectat si comenzi interne. Pentru acestea nu se vor lista dispozitii!",0+48,"Atentie")
		Endcase
		
		If lnNrAgenti>0
			If amessagebox("Exista comenzi selectate pentru care au fost deja listate dispozitiile. Doriti sa le modificati datele?",4+48+256,"Atentie")<>6
				Use In crstempcomlivrare
				Return
			Endif
		Endif
		
		Select crstempcomlivrare
		Scatter Name podetlivrare Blank
		podetlivrare.data_comanda=ltMaxDataComanda
		podetlivrare.data_livrat=get_ora()
		ofrmlivrare=Createobject('frm_livrare')
		ofrmlivrare.Show(1)
		
		If pniesire=1
			Private pcNrLivrare,pcDataOra,pcText
			Select crstempcomlivrare
			Scan For interna<>1
				Store [] To pcNrLivrare
				lnIdComanda=id_comanda
				lcSql = [begin pack_comenzi.livreaza_comanda(] + Alltrim(Str(lnIdComanda)) + [,] + ;
					IIF(Empty(Nvl(podetlivrare.id_agent,'')),[NULL],[?podetlivrare.id_agent]) + [,] + ;
					IIF(Empty(Nvl(podetlivrare.id_delegat,'')),[NULL],[?podetlivrare.id_delegat]) + [,] + ;
					IIF(Empty(Nvl(podetlivrare.id_masina,'')),[NULL],[?podetlivrare.id_masina]) + ;
					[,to_date(']+Ttoc(podetlivrare.data_livrat,1)+[','YYYYMMDDHH24MISS'),] + ;
					Alltrim(Str(gnIdUtil)) + [,?@pcNrLivrare); end;]
				lnSucces = goExecutor.oExecute(lcSql)
				If lnSucces < 0
					amessagebox(goExecutor.cEroare,0+16,"Eroare")
					Return
				Endif
		
				Update crscomenzi Set id_agent=podetlivrare.id_agent,id_delegat=podetlivrare.id_delegat,id_masina=podetlivrare.id_masina,data_livrat=podetlivrare.data_livrat,;
					nume_agent=podetlivrare.nume_agent,nume_delegat=podetlivrare.nume_delegat,nrinmat=podetlivrare.nrinmat,nr_livrare=pcNrLivrare Where id_comanda=lnIdComanda
		
				Select crstempcomlivrare
				Replace id_agent With podetlivrare.id_agent,id_delegat With podetlivrare.id_delegat,id_masina With podetlivrare.id_masina,;
					data_livrat With podetlivrare.data_livrat,	nume_agent With Nvl(podetlivrare.nume_agent,[]), nume_delegat With Nvl(podetlivrare.nume_delegat,[]),;
					nrinmat With Nvl(podetlivrare.nrinmat,[]),nr_livrare With pcNrLivrare
		
				Scatter Name olivrare
				olivrare.serie_bi=Iif(Empty(Nvl(podetlivrare.serie_bi,[])),Replicate([_],4),Alltrim(podetlivrare.serie_bi))
				olivrare.numar_bi=Iif(Empty(Nvl(podetlivrare.numar_bi,[])),Replicate([_],8),Alltrim(podetlivrare.numar_bi))
				olivrare.eliberatde=Iif(Empty(Nvl(podetlivrare.eliberatde,[])),Replicate([_],24),Alltrim(podetlivrare.eliberatde))
				lcSql = [select codmat,denumire,um,cantitate,pret,sysdate as dataora from ] + This.cSchema + [.vcomenzi_elemente ] + ;
					[where id_comanda=?olivrare.id_comanda]
				lcCursor = [crslivrarecomanda]
				lnSucces = goExecutor.oExecute(lcSql,lcCursor)
				If lnSucces < 0
					amessagebox(goExecutor.cEroare,0+16,"Eroare")
					Return
				Endif
		
				If Reccount('crslivrarecomanda')>0
		*!*				this.AlwaysOnTop=.F.
					Select crslivrarecomanda
					pcDataOra=Ttoc(dataora)
					pcText = Space(12)+'Veți elibera produsele de mai jos către '+Alltrim(olivrare.nume)+;
						' prin delegatul '+Alltrim(olivrare.nume_delegat)+' cu delegația nr. '+Replicate([_],20)+;
						', buletin de identitate seria '+olivrare.serie_bi+' nr.'+olivrare.numar_bi+;
						' eliberat de '+olivrare.eliberatde+' .'
		*!*	modificare	v 2.0.11
		*!*				Keyboard "{CTRL+F10}"
		*!*				Report Form dispozitie_livrare To Printer Prompt Preview
					goExport.export2frx([crslivrarecomanda],[dispozitie_livrare], , , , , , .T.)
		*!*	modificare	v 2.0.11	^
		*!*				this.AlwaysOnTop=.T.
				Else
					amessagebox("Nu exista elemente pe comanda "+Alltrim(olivrare.nr_comanda)+" !",0+48,"Atentie")
				Endif
		
				If Used('crslivrarecomanda')
					Use In crslivrarecomanda
				Endif
		
				Select crstempcomlivrare
			Endscan
		*!*		this.actualizeaza_grid1()
		
			Select crscomenzi
			Locate For id_comanda = olivrare.id_comanda
		Endif
		
		Use In crstempcomlivrare
		This._grdrow1.SetFocus()
		RELEASE podetlivrare,olivrare
	ENDPROC

	PROCEDURE do_modifica
		Lparameters tnTip
		&&	0	-		modificare
		&&	1	-		vine din adaugare
		If Reccount('crscomenzi')>0
			Local lnTip
			lnTip = Iif(Empty(tnTip),0,1)
			Select crscomenzi
			Scatter Name loRec
			Do Case
				Case loRec.inchisa=1
					amessagebox("Aceasta comanda este pe o lucrare inchisa si nu mai poate fi modificata!",0+48,"Atentie")
				Case loRec.facturat=1
					amessagebox("Aceasta comanda a fost facturata si nu mai poate fi modificata!",0+48,"Atentie")
				Otherwise
					Private pniesire,pcNrComanda
					Store [] To pcNrComanda
					pniesire=0
					If Used('crscomanda_curenta')
						Use In crscomanda_curenta
					Endif
					*!*	modificare	v 2.0.24
					loBackupXML = Createobject("BackupXML", "comanda_" + Alltrim(Str(loRec.id_comanda))) && oproceduri_comune.prg
					AddProperty(loRec,"oBackupXML",loBackupXML)
					AddProperty(loRec,"lcomandareincarcata",.F.)
					If loBackupXML.ExistsBackupSet()
						ldDataOraBackupXML = loBackupXML.ReadValue("DATAORA_UM")
						*!*	modificare	v 2.0.26 : am adaugat conditia EMPTY...
						If Ttoc(Nvl(Iif(Empty(ldDataOraBackupXML),Null,ldDataOraBackupXML),Datetime(1900,1,1))) = Ttoc(Nvl(Iif(Empty(loRec.dataora_um),Null,loRec.dataora_um),Datetime(1900,1,1)))
							If amessagebox("S-au gasit modificari care nu au fost salvate in baza de date.Doriti sa le incarcati?",4+32,"Confirmare") = 6
								loBackupXML.RestoreBackupSet()
								loRec.lcomandareincarcata = .T.
							Else
								loBackupXML.DeleteBackUpSet()
							Endif
						Else
							loBackupXML.DeleteBackUpSet()
						Endif
					Endif
					If !loRec.lcomandareincarcata
						If lnTip = 0
							Select a.*,Round(a.Pret*a.cantitate,gnPc) As valoare From crscomenzielemente a Into Cursor crscomanda_curenta Readwrite
						Else
							Select a.*,Round(a.Pret*a.cantitate,gnPc) As valoare From crscomenzielemente a Where 1=2 Into Cursor crscomanda_curenta Readwrite
						Endif
						loBackupXML.SaveBackupSet("crscomanda_curenta")
						loBackupXML.SaveBackupSet("DATAORA_UM","VARIABLE",loRec.dataora_um)
					Endif
					*!*			If lnTip = 0
					*!*				Select a.*,Round(a.Pret*a.cantitate,gnPc) As valoare From crscomenzielemente a Into Cursor crscomanda_curenta Readwrite
					*!*			Else
					*!*				Select a.*,Round(a.Pret*a.cantitate,gnPc) As valoare From crscomenzielemente a Where 1=2 Into Cursor crscomanda_curenta Readwrite
					*!*			Endif
					*!*	modificare	v 2.0.24	^
					*!* modificare 21.01.2008
					Do Case
						Case Inlist(loRec.interna,2,5)	&&	modificare	v 2.0.20
							If lnTip = 0 And Reccount('crscomanda_curenta')>0
								Select crscomanda_curenta
								lnIdPol = id_pol
							Else
								loCauta = caut_politici_curente_utilizator()
								If !Empty(Nvl(loCauta.id_pol,0))
									lnIdPol = loCauta.id_pol
								Else
									Select crscomenzi
									Return
								Endif
							Endif
							update_articole_politica(lnIdPol)
						Case loRec.interna = 3
							lcOptiune = [IDPOLITICAPRET]
							update_articole_politica_comenzi(lcOptiune)
						Otherwise
							lcOptiune = [ID_LISTA_PRETURI_PV]
							update_articole_politica_comenzi(lcOptiune)
					Endcase
					*!* Do Case
					*!* Case loRec.interna = 2
					*!* lcOptiune = [IDPOLITICAPRETC]
					*!* Case loRec.interna = 3
					*!* lcOptiune = [IDPOLITICAPRET]
					*!* Otherwise
					*!* lcOptiune = [ID_LISTA_PRETURI_PV]
					*!* Endcase
					*!* update_articole_politica_comenzi(lcOptiune)
					*!* modificare 21.01.2008 ^
					*!*	modificare v 2.0.8
					If lnTip = 0 And Reccount('crscomanda_curenta') > 0
						*!*	modificare v 2.0.11
						If Reccount('v_articole') = 0
							amessagebox("Politica aleasa initial pe aceasta comanda nu mai este valabila!",48,"Atentie")
							Use In v_articole
							Return
						Else
							*!*	modificare v 2.0.11	^
							Select v_articole
							lnIdPolNArt = id_pol
							lnPretCuTvaNArt = pret_cu_tva
							Select crscomanda_curenta
							lnIdPolVArt = id_pol
							lnPretCuTvaVArt = pret_cu_tva
							If lnPretCuTvaNArt <> lnPretCuTvaVArt
								amessagebox("Politica aleasa initial pe aceasta comanda era " + Iif(lnPretCuTvaVArt=1,[cu],[fara]) + " TVA," + ;
									"iar acum este " + Iif(lnPretCuTvaNArt=1,[cu],[fara]) + " TVA!",48,"Atentie")
								Use In v_articole
								Return
							Endif
							If lnIdPolNArt <> lnIdPolVArt
								amessagebox("Politica aleasa initial pe aceasta comanda este diferita de politica de preturi implicita!",48,"Atentie")
								Use In v_articole
								Return
							Endif
							*!*	modificare v 2.0.11
						Endif
						*!*	modificare v 2.0.11	^
					Endif
					*!*	modificare v 2.0.8	^
					*!*	modificare v 2.0.16
					*!*			Do Adauga_Modifica_Inregistrare With "comenzi",loRec,loRec.id_comanda,"UPDATE"
					Private pcMesajVerificareCom
					pcMesajVerificareCom = []
					lcSql = [begin ?@pcMesajVerificareCom:=pack_comenzi.verifica_acces_comanda(]+Alltrim(Str(loRec.id_comanda))+[); end;]
					If !goExecutor.oExecuta(lcSql)
						pniesire = 0
					Else
						AddProperty(loRec,"cmesajverificare",pcMesajVerificareCom)
						Do Adauga_Modifica_Inregistrare With "comenzi",loRec,loRec.id_comanda,"UPDATE"
						If Isnull(pcMesajVerificareCom)
							lcSql = [begin pack_comenzi.deblocheaza_acces_comanda(] + Alltrim(Str(loRec.id_comanda)) + [); end;]
							goExecutor.oExecuta(lcSql)
						Endif
					Endif
					Release pcMesajVerificareCom
					*!*	modificare v 2.0.16	^
					If pniesire=1
						*!*	modificare	v 2.0.24
						loBackupXML.DeleteBackUpSet()
						*!*	modificare	v 2.0.24	^
						If loRec.selectat=1
							Update crscomenzi Set nr_comanda=loRec.nr_comanda,id_part=loRec.id_part,nume=loRec.nume,;
								data_comanda=loRec.data_comanda,interna=loRec.interna,data_livrare=loRec.data_livrare, ;
								tip_comanda = Iif(loRec.interna = 1,'INTERNA',Iif(loRec.interna = 2,'EXTERNA - SIMPLA',Iif(loRec.interna = 5,'EXTERNA - PE BAZA DE CONTRACT','SUBUNITATE'))) ;
								where id_comanda=loRec.id_comanda
						Endif
						This.actualizeaza_grid1()
						Select crscomenzi
						Locate For id_comanda=loRec.id_comanda
						This._grdrow1.SetFocus()
					Endif
					*!*	modificare	v 2.0.24
					Release loBackupXML
					*!*	modificare	v 2.0.24	^
			Endcase
		Else
			amessagebox("Nu exista inregistrari in vizualizare!",0+48,"Atentie")
		Endif
		
	ENDPROC

	PROCEDURE do_relisteaza_disp
		Private pniesire
		pniesire=0
		If Used('crstempcomlivrare')
			Use In crstempcomlivrare
		Endif
		Select * From crscomenzi Where selectat=1 Into Cursor crstempcomlivrare Readwrite
		If Reccount('crstempcomlivrare')=0
			amessagebox("Selectati cel putin o comanda!",0+48,"Atentie")
			Use In crstempcomlivrare
			Return
		Endif
		
		Select crstempcomlivrare
		Calculate Count() For interna=1 To lnComenziInterne
		Calculate Count() For Empty(nr_livrare) Or Isnull(nr_livrare) To lnNrLivrari
		
		If lnComenziInterne=Reccount('crstempcomlivrare')
			amessagebox("Pentru comenzile interne nu se pot lista dispozitii!",0+48,"Atentie")
			Use In crstempcomlivrare
			Return
		Else
			lcMesajAtentionare = []
			If lnComenziInterne>0
				lcMesajAtentionare = [Ati selectat si comenzi interne. Pentru acestea nu se vor lista dispozitii!] + Chr(13) + Chr(10)
			Endif
			If lnNrLivrari > 0
				lcMesajAtentionare = lcMesajAtentionare + [Ati selectat si comenzi care nu au generate numere de livrare.] + ;
					CHR(13) + Chr(10) + Chr(9) + [Pentru acestea trebuie sa apasati butonul 'Listeaza dispozitii de livrare'!]
			Endif
			If !Empty(lcMesajAtentionare)
				amessagebox(lcMesajAtentionare,0+48,"Atentie")
			Endif
		Endif
		
		Select crstempcomlivrare
		Private pcDataOra,pcText
		Store '' To pcDataOra,pcText
		Select crstempcomlivrare
		Scan For interna<>1 And !Empty(Nvl(nr_livrare,0))
			Scatter Name olivrare
			lcSql = [select codmat,denumire,um,cantitate,pret,sysdate as dataora from ] + This.cSchema + [.vcomenzi_elemente ] + ;
				[where id_comanda= ?olivrare.id_comanda]
			lcCursor = [crslivrarecomanda]
			lnSucces = goExecutor.oExecute(lcSql,lcCursor)
			If lnSucces < 0
				amessagebox(goExecutor.cEroare,0+16,"Eroare")
				Return
			Endif
		
			If Reccount('crslivrarecomanda')>0
		*!*				this.AlwaysOnTop=.F.
				Select crslivrarecomanda
				olivrare.serie_bi=Iif(Empty(Nvl(olivrare.serie_bi,[])),Replicate([_],4),Alltrim(olivrare.serie_bi))
				olivrare.numar_bi=Iif(Empty(Nvl(olivrare.numar_bi,[])),Replicate([_],8),Alltrim(olivrare.numar_bi))
				olivrare.eliberatde=Iif(Empty(Nvl(olivrare.eliberatde,[])),Replicate([_],24),Alltrim(olivrare.eliberatde))
		
				pcDataOra=Ttoc(dataora)
				pcText = Space(12)+'Veți elibera produsele de mai jos către '+Alltrim(olivrare.nume)+;
					' prin delegatul '+Alltrim(olivrare.nume_delegat)+' cu delegația nr. '+Replicate([_],20)+;
					', buletin de identitate seria '+olivrare.serie_bi+' nr.'+olivrare.numar_bi+;
					' eliberat de '+olivrare.eliberatde+' .'
		*!*	modificare	v 2.0.11
		*!*			Keyboard "{CTRL+F10}"
		*!*			Report Form dispozitie_livrare To Printer Prompt Preview
				goExport.export2frx([crslivrarecomanda],[dispozitie_livrare], , , , , , .T.)
		*!*	modificare	v 2.0.11	^
		*!*				this.AlwaysOnTop=.T.
			Else
				amessagebox("Nu exista elemente pe comanda "+Alltrim(olivrare.nr_comanda)+" !",0+48,"Atentie")
			Endif
		
			If Used('crslivrarecomanda')
				Use In crslivrarecomanda
			Endif
		
			Select crstempcomlivrare
		Endscan
		*!*		this.actualizeaza_grid1()
		Select crscomenzi
		If Type('olivrare')<>'U'
			Locate For id_comanda = olivrare.id_comanda
		Endif
		
		Use In crstempcomlivrare
		This._grdrow1.SetFocus()
		Release olivrare
	ENDPROC

	PROCEDURE do_reset
		THIS.filtru_pretty = ""
		THIS.filtru_pretty_ro = ""
		THIS.filtru_pretty_ro_full = ""
		IF TYPE("this.but_start_criterii1") = 'O'
			THIS.but_start_criterii1.TOOLTIPTEXT=THIS.filtru_pretty_ro
			THIS.but_start_criterii1.SETFOCUS
			THIS.but_start_criterii1.pornit = "nu"
		ENDIF 	
		THIS.do_cauta()
		THIS.REFRESH
		
		
	ENDPROC

	PROCEDURE do_sterge
		If Reccount('crscomenzi')>0
			Select crscomenzi
			Scatter Name loRec
			Do Case
				Case loRec.inchisa=1
					amessagebox("Aceasta comanda este pe o lucrare inchisa si nu mai poate fi stearsa!",0+48,"Atentie")
				Case loRec.facturat=1
					amessagebox("Aceasta comanda a fost facturata si nu mai poate fi stearsa!",0+48,"Atentie")
				Otherwise
					Private pniesire
					pniesire=0
					*!*	modificare v 2.0.16
					*!*					Do STERGE_INREGISTRARE With "comenzi",loRec.id_comanda
					Private pcMesajVerificareCom
					pcMesajVerificareCom = []
					lcSql = [begin ?@pcMesajVerificareCom:=pack_comenzi.verifica_acces_comanda(]+Alltrim(Str(loRec.id_comanda))+[); end;]
					lnSucces = goExecutor.oExecute(lcSql)
					If lnSucces < 0
						amessagebox(goExecutor.cEroare,16,"Eroare")
						pniesire = 0
					Else
						If !Isnull(pcMesajVerificareCom)
							amessagebox(pcMesajVerificareCom,48,"Atentie")
							pniesire = 0
						Else
							Do STERGE_INREGISTRARE With "comenzi",loRec.id_comanda
							lcSql = [begin pack_comenzi.deblocheaza_acces_comanda(] + Alltrim(Str(loRec.id_comanda)) + [); end;]
							lnSucces = goExecutor.oExecute(lcSql)
							If lnSucces < 0
								amessagebox(goExecutor.cEroare,16,"Eroare")
							Endif
						Endif
					Endif
					Release pcMesajVerificareCom
					*!*	modificare v 2.0.16	^
					If pniesire=1
						If loRec.selectat=1
							Update crscomenzi Set selectat=0 Where id_comanda=loRec.id_comanda
						Endif
						This.actualizeaza_grid1()
					Endif
			Endcase
		Else
			amessagebox("Nu exista inregistrari in vizualizare!",0+48,"Atentie")
		Endif
	ENDPROC

	PROCEDURE Init
		gcAcces=[1;2;3;4;]
		DoDefault()
		
	ENDPROC

	PROCEDURE But_attach1.Click
		Local lcSql, llSucces
		PRIVATE pnIdComanda, pnIdVanzare
		pnIdComanda = crsComenzi.id_comanda
		pnIdVanzare = 0
		lnIdPart = crsComenzi.id_part
		
		IF !EMPTY(NVL(m.lnIdPart,0)) AND AMESSAGEBOX('Doriti sa asociati comanda pe o factura deja emisa?',4+32,_Screen.Caption) = 6
			loCauta = caut_facturi_multiple_client(m.lnIdPart)
			If !Isnull(loCauta) And !Empty(NVL(loCauta.id_vanzare,0))
				pnIdVanzare = loCauta.id_vanzare
			
				lcSql = [BEGIN pack_comenzi.adauga_comanda_pe_factura(?pnIdComanda, ?pnIdVanzare); end;]
				llSucces = goExecutor.oExecuta(m.lcSql) 
				IF m.llSucces 
					AMESSAGEBOX('Comanda a fost asociata pe factura!',0+64,_screen.Caption)
				ENDIF 
			ENDIF
		ENDIF
		
		
	ENDPROC

	PROCEDURE But_reset_criterii1.Click
		LOCAL lcFiltru, lcComenziInitial
		
		THIS.Parent.filtru_pretty = ""
		THIS.Parent.filtru_pretty_ro = ""
		THIS.Parent.filtru_pretty_ro_full = ""
		
		IF TYPE("this.parent.but_start_criterii1") = 'O'
			THIS.Parent.but_start_criterii1.TOOLTIPTEXT=THIS.Parent.filtru_pretty_ro
			THIS.Parent.but_start_criterii1.SETFOCUS
			THIS.Parent.but_start_criterii1.pornit = "nu"
			IF PEMSTATUS(this.Parent, 'oCriterii',5)
				REMOVEPROPERTY(this.Parent, "oCriterii")
			ENDIF 	
		ENDIF 	
		
		lnComenziInitial = IIF(!EMPTY(NVL(m.gnComenziInitial,0)), INT(m.gnComenziInitial), 3) && nefacturate
		lcfiltru = [Stare facturat;nofiled;] + ALLTRIM(STR(m.lnComenziInitial)) + [;|Stare lucrare;nofiled;1;] && facturate sau recente 90 zile, deschise
		
		This.Parent.but_start_criterii1.loadfiltru(m.lcFiltru)
		THIS.Parent.REFRESH
	ENDPROC

	PROCEDURE But_start_criterii1.loadcriterii
		PARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		#DEFINE crlf CHR(13)+CHR(10)
		
		lcStringCriterii="Data comandă\data_comanda\D\none\" + crlf + ;
			"Numar comanda\nr_comanda\T\none\" + crlf + ;
			"Beneficiar\nume\T\none\"+ crlf + ;	
			"Client\nume\T\id_part\nom_parteneri"+ crlf + ;	
			"Data livrare\data_comanda\D\none\" + crlf + ;	
			"Agent\nume_agent\T\id_agent\nom_parteneri"+ crlf + ;	
			"Delegat\nume_delegat\T\id_delegat\nom_parteneri"+ crlf + ;		
			"Lucrare\nrord\T\id_lucrare\nom_lucrare" + crlf + ;
			"Contract\numar_contract\T\id_ctr\nom_contracte" + crlf + ;	
			"Masina\nrinmat\T\none\"+ crlf + ;	
			"Data introducere\trunc(dataora)\D\none\" + crlf + ;
			"Oper. introducere\utilizator\T\id_util\nom_utilizator" + crlf + ;	
			"Stare facturat\nofiled\A\Toate,Facturate,Nefacturate," + ;
				"Nefacturate sau Recente 1 zi,Nefacturate sau Recente 3 zile,Nefacturate sau Recente 7 zile," + ;
				"Nefacturate sau Recente 15 zile,Nefacturate sau Recente 30 zile,Nefacturate sau Recente 60 zile,Nefacturate sau Recente 90 zile#" + ;
				"1=1,facturat=1,facturat=0," + ;
				"(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-1)," + ;
				"(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-3)," + ;
				"(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-7)," + ;
				"(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-15)," + ;
				"(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-30),(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-60),(facturat=0 or trunc(data_comanda)>=trunc(sysdate)-90)\" + crlf + ;
			"Stare lucrare\nofiled\A\Deschise,Inchise,Toate#inchisa=0,inchisa=1,1=1\" + crlf + ;
			"Tip\nofiled\A\Toate,Interne,Externe,Subunitati#1=1,interna=1,(interna = 2 or interna = 5),interna=3\"			
		
		DODEFAULT()
		
	ENDPROC

	PROCEDURE _grdrow1.AfterRowColChange
		*!* 03.03.2015
		*!* marius.mutu
		*!* + goComanda pentru facturare comanda
		
		Lparameters nColIndex
		*!*	DoDefault()
		SELECT crsComenzi
		SCATTER NAME goComanda MEMO 
		
		If This.RowColChange <> 2
			this.Parent.but_factura1.Visible = (goComanda.facturat = 0)
			this.Parent.but_factura1.Refresh()
		
			lcFiltru=[id_comanda=]+Alltrim(Str(crscomenzi.id_comanda))
			This.Parent.actualizeaza_grid2(lcFiltru)
		Endif
	ENDPROC

	PROCEDURE _grdrow1.Init
		* Nu sterge se suprascrie cu Arial Narrow
	ENDPROC

	PROCEDURE _grdrow2.Init
		* Nu sterge se suprascrie cu Arial Narrow
	ENDPROC

ENDDEFINE

DEFINE CLASS ct_lucrari_detalii AS _ctfrmbase OF "_ct_base.vcx" 
 	*< CLASSDATA: Baseclass="container" Timestamp="" Scale="Pixels" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="_grdrow1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNrord.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cNrord.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_lucrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cData_lucrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cExplicatie.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cExplicatie.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cTermen_executie.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cTermen_executie.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataora.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cDataora.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cUtilizator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cUtilizator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cInchisa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cInchisa._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cExecutata.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow1.cExecutata._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCantitate.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCantitate.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cUM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cUM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCantitate2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCantitate2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cUM2.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cUM2.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCodmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow3.cCodmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNr_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNr_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cData_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cData_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNume.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cNume.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cData_livrare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cData_livrare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cTip_comanda.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_grdrow2.cTip_comanda.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_lucrari_elemente" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_comenzi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_start_criterii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset_criterii1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: actualizeaza_grid3
		*p: nid_sectie
	*</DefinedPropArrayMethod>

	*<PropValue>
		BackStyle = 0
		cgridsortlist = _grdrow1,_grdrow2,_grdrow3
		Height = 497
		Name = "ct_lucrari_detalii"
		nid_sectie = 0
		Width = 781
		Gridsort1.Height = 17
		Gridsort1.Left = 540
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 0
		Gridsort1.Width = 32
		_ct_controller_keypress1.Name = "_ct_controller_keypress1"
	*</PropValue>

	ADD OBJECT '_grdrow1' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 8, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		Height = 282, ;
		Left = 9, ;
		Name = "_grdrow1", ;
		Panel = 1, ;
		RecordSource = "crslucrari", ;
		RowHeight = 19, ;
		TabIndex = 8, ;
		Top = 12, ;
		Width = 492, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "nrord", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNrord", ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "data_lucrare", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_lucrare", ;
		Column2.Width = 84, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "explicatie", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cExplicatie", ;
		Column3.Width = 142, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "termen_executie", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Name = "cTermen_executie", ;
		Column4.Width = 99, ;
		Column5.ColumnOrder = 7, ;
		Column5.ControlSource = "dataora", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cDataora", ;
		Column5.Width = 93, ;
		Column6.ColumnOrder = 8, ;
		Column6.ControlSource = "utilizator", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cUtilizator", ;
		Column6.Width = 96, ;
		Column7.ColumnOrder = 4, ;
		Column7.ControlSource = "inchisa", ;
		Column7.FontName = "Arial", ;
		Column7.FontSize = 10, ;
		Column7.Name = "cInchisa", ;
		Column7.Sparse = .F., ;
		Column7.Width = 43, ;
		Column8.ColumnOrder = 6, ;
		Column8.ControlSource = "executata", ;
		Column8.FontName = "Arial", ;
		Column8.FontSize = 10, ;
		Column8.Name = "cExecutata", ;
		Column8.Sparse = .F., ;
		Column8.Width = 63
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdrow1.cData_lucrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data lucrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cData_lucrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cDataora.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data si ora ad.", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cDataora.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cExecutata._checkbox1' AS _checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 36, ;
		Name = "_checkbox1", ;
		Top = 35
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT '_grdrow1.cExecutata.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Executata", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cExplicatie.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Explicatia", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cExplicatie.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cInchisa._checkbox1' AS _checkbox WITH ;
		Alignment = 2, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 28, ;
		Name = "_checkbox1", ;
		Top = 59
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT '_grdrow1.cInchisa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Inchisa", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNrord.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr. lucrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cNrord.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cTermen_executie.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Termen executie", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cTermen_executie.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow1.cUtilizator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Utilizator", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow1.cUtilizator.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2' AS _grdrow WITH ;
		Anchor = 14, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		Height = 160, ;
		Left = 9, ;
		Name = "_grdrow2", ;
		Panel = 1, ;
		RecordSource = "crscomenzi2", ;
		RowHeight = 19, ;
		TabIndex = 9, ;
		Top = 320, ;
		Width = 480, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "nr_comanda", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cNr_comanda", ;
		Column2.ColumnOrder = 2, ;
		Column2.ControlSource = "data_comanda", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cData_comanda", ;
		Column2.Width = 84, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "nume", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cNume", ;
		Column3.Width = 160, ;
		Column4.ColumnOrder = 4, ;
		Column4.ControlSource = "data_livrare", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.Name = "cData_livrare", ;
		Column4.Width = 82, ;
		Column5.ControlSource = "tip_comanda", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cTip_comanda"
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdrow2.cData_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cData_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cData_livrare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data livrare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cData_livrare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cNr_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Nr.comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cNr_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cNume.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Beneficiar", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cNume.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow2.cTip_comanda.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Tip comanda", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow2.cTip_comanda.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3' AS _grdrow WITH ;
		Anchor = 13, ;
		ColumnCount = 6, ;
		DeleteMark = .F., ;
		FontSize = 10, ;
		Height = 430, ;
		Left = 513, ;
		Name = "_grdrow3", ;
		Panel = 1, ;
		RecordSource = "crslucrarielemente", ;
		RowHeight = 19, ;
		TabIndex = 10, ;
		Top = 52, ;
		Width = 264, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cDenumire", ;
		Column1.Width = 147, ;
		Column2.ControlSource = "cantitate", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.InputMask = (get_mask(14,IIF(TYPE("gnPcant")='U',3,gnPcant))), ;
		Column2.Name = "cCantitate", ;
		Column2.Width = 56, ;
		Column3.ControlSource = "um", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cUM", ;
		Column3.Width = 33, ;
		Column4.ControlSource = "cantitate2", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,IIF(TYPE("gnPcant")='U',3,gnPcant))), ;
		Column4.Name = "cCantitate2", ;
		Column4.Width = 67, ;
		Column5.ControlSource = "um2", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cUM2", ;
		Column5.Width = 43, ;
		Column6.ControlSource = "codmat", ;
		Column6.FontName = "Arial", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cCodmat", ;
		Column6.Width = 77
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT '_grdrow3.cCantitate.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cCantitate.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3.cCantitate2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate 2", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cCantitate2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3.cCodmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod material", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cCodmat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Articol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cDenumire.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3.cUM.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "U.M.", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cUM.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT '_grdrow3.cUM2.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "U.M. 2", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT '_grdrow3.cUM2.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

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

	ADD OBJECT 'But_modifica1' AS but_modifica WITH ;
		Anchor = 8, ;
		Left = 689, ;
		Name = "But_modifica1", ;
		TabIndex = 13, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_nou1' AS but_nou WITH ;
		Anchor = 8, ;
		Left = 659, ;
		Name = "But_nou1", ;
		TabIndex = 14, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_reset_criterii1' AS but_reset_criterii WITH ;
		Anchor = 9, ;
		Left = 601, ;
		Name = "But_reset_criterii1", ;
		Picture = ..\grafice\reset_sus.bmp, ;
		Top = 3, ;
		Visible = .T.
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_start_criterii1' AS but_start_criterii WITH ;
		Anchor = 9, ;
		Comment = "*:OnResize=RT", ;
		Left = 630, ;
		Name = "But_start_criterii1", ;
		Picture = ..\grafice\find_sus.bmp, ;
		Top = 3
		*< END OBJECT: ClassLib="ocriterii.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_sterge1' AS but_sterge WITH ;
		Anchor = 8, ;
		Left = 719, ;
		Name = "But_sterge1", ;
		TabIndex = 12, ;
		Top = 3
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'lb_comenzi' AS lb_simplu WITH ;
		Anchor = 6, ;
		Caption = "Comenzi asociate", ;
		Left = 9, ;
		Name = "lb_comenzi", ;
		TabIndex = 17, ;
		Top = 299
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'lb_lucrari_elemente' AS lb_simplu WITH ;
		Anchor = 9, ;
		Caption = "Elemente lucrare", ;
		Height = 18, ;
		Left = 513, ;
		Name = "lb_lucrari_elemente", ;
		TabIndex = 16, ;
		Top = 31, ;
		Width = 100
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />
	
	PROCEDURE actualizeaza_cursoare
		*!*	modificare v 2.0.11 : am adaugat This.nid_sectie si gnId_sectie
		Local llCautare
		llCautare = .F.
		If !Used('crslucrari') Or gcS!=This.cSchema Or Nvl(gnId_sectie,0)!= This.nid_sectie
			If gcS!=This.cSchema Or Nvl(gnId_sectie,0)!=This.nid_sectie
				llCautare = .T.
			Endif
			This.cSchema=gcS
			This.nid_sectie = Nvl(gnId_sectie,0)
			This.creeaza_cursoare()
		*!*		If llCautare
		*!*			This.do_cauta()
		*!*		Endif
		Endif
	ENDPROC

	PROCEDURE actualizeaza_grid1
		Lparameters tcFiltru
		
		If Empty(tcFiltru)
			lcFiltru=polucrari.ca_baza1.cfiltru
		Else
			lcFiltru=tcFiltru
		Endif
		
		This._grdrow1.salveaza_grid()
		polucrari.ca_baza1.cfiltru=lcFiltru
		polucrari.ca_baza1.afisare()
		This._grdrow1.incarca_grid()
		
		* lucrari inchise: italic
		* lucrari executate: gri
		
		This._grdrow1.SetAll("DynamicFontItalic","IIF(inchisa=1,.T.,.F.)","Column")
		This._grdrow1.SetAll("DynamicForeColor","IIF(executata=1,RGB(128,128,128),RGB(0,0,0))","Column")
	ENDPROC

	PROCEDURE actualizeaza_grid2
		Lparameters tcFiltru
		
		If Empty(tcFiltru)
			lcFiltru=pocomenzi2.ca_baza1.cfiltru
		Else
			lcFiltru=tcFiltru
		Endif
		
		This._grdrow2.salveaza_grid()
		pocomenzi2.ca_baza1.cfiltru=lcFiltru
		pocomenzi2.ca_baza1.afisare()
		This._grdrow2.incarca_grid()
	ENDPROC

	PROCEDURE actualizeaza_grid3
		Lparameters tcFiltru
		
		If Empty(tcFiltru)
			lcFiltru=polucrarielemente.ca_baza1.cfiltru
		Else
			lcFiltru=tcFiltru
		Endif
		
		This._grdrow3.salveaza_grid()
		polucrarielemente.ca_baza1.cfiltru=lcFiltru
		polucrarielemente.ca_baza1.afisare()
		This._grdrow3.incarca_grid()
	ENDPROC

	PROCEDURE creeaza_cursoare
		Local lcSchema,lcSelect,lcOrder,lcFiltru,llAfiseaza
		Store '' To polucrari,pocomenzi2,polucrarielemente
		This._grdrow1.salveaza_grid()
		This._grdrow2.salveaza_grid()
		This._grdrow3.salveaza_grid()
		
		lcSchema=[id_lucrare n(20),nrord c(30),termen_executie t,id_lucrari_detalii n(20),explicatie c(100),data_lucrare t,]+;
			[dataora t,utilizator c(30),inchisa n(1),executata n(1)]
		lcSelect=[select id_lucrare,nrord,termen_executie,id_lucrari_detalii,explicatie,data_lucrare,]+;
			[dataora,utilizator,inchisa,executata from vlucrari_detalii where 1=2]
		lcOrder=[data_lucrare]
		lcFiltru = [1=2]
		llAfiseaza = .F.
		gencursor('polucrari','crslucrari',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza)
		polucrari.ca_baza1.afisare()
		
		lcSchema=[id_comanda n(20),id_lucrare n(20),id_part n(20),id_gestiune n(20),]+;
			[nr_comanda c(100),data_comanda t,nume c(70),data_livrare t,interna n(1),tip_comanda c(20)]
		lcSelect=[select id_comanda,id_lucrare,id_part,id_gestiune,]+;
			[nr_comanda,data_comanda,nume,data_livrare,interna,tip_comanda ]+;
			[from vcomenzi where 1=2]
		lcOrder=[data_comanda]
		lcFiltru = [1=2]
		llAfiseaza = .F.
		gencursor('pocomenzi2','crscomenzi2',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza)
		pocomenzi2.ca_baza1.afisare()
		
		lcSchema=[id_lucrare n(20),denumire c(100),cantitate n(16,3),um c(10),cantitate2 n(16,3),um2 c(10),codmat c(100)]
		lcSelect=[select id_lucrare,denumire,cantitate,um,cantitate2,um2,codmat from vlucrari_elemente where 1=2]
		lcOrder=[]	&&	[codmat,denumire]
		lcFiltru = [id_lucrare = -9999999]
		llAfiseaza = .F.
		gencursor('polucrarielemente','crslucrarielemente',lcSelect,lcFiltru,lcSchema,lcOrder,llAfiseaza)
		polucrarielemente.ca_baza1.afisare()
		
		This._grdrow1.incarca_grid()
		This._grdrow2.incarca_grid()
		This._grdrow3.incarca_grid()
	ENDPROC

	PROCEDURE do_adauga
		Private pniesire,pcNrOrd
		Store [] To pcNrOrd
		pniesire=0
		Select crslucrari
		Scatter Name loRec Blank
		goExecutor.oFunction2Value([pack_comenzi.genereaza_nr_lucrare],@pcNrOrd)
		loRec.nrord=pcNrOrd
		Do Adauga_Modifica_Inregistrare With "lucrari_detalii",loRec,,"INSERT"
		If pniesire=1
			This.actualizeaza_grid1()
			Select crslucrari
			Locate For data_lucrare=loRec.data_lucrare And nrord=loRec.nrord
			This._grdrow1.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta
		Local lcFiltru
		lcFiltru = [id_sectie = ] + Alltrim(Str(This.nid_sectie))
		
		IF LEN(THIS.filtru_pretty)>0     
			lcFiltru = m.lcFiltru+" and (" + ALLTRIM(THIS.filtru_pretty) + ")"    
		ENDIF
		
		IF ![inchisa]$m.lcFiltru
			lcFiltru = lcFiltru + [ and inchisa = 0]
		ENDIF 
		
		This.actualizeaza_grid1(lcFiltru)
		
		If Reccount('crslucrari')>0
			This._grdrow1.SetFocus()
		Else
			If Reccount('crscomenzi2')>0
				This.actualizeaza_grid2([1=2])
			Endif
			If Reccount('crslucrarielemente')>0
				This.actualizeaza_grid3([1=2])
			ENDIF
			IF this.lShowRezultate
				amessagebox("Cautarea nu a intors rezultate!",0+64,"Info cautare")
			ENDIF 	
		Endif
		
	ENDPROC

	PROCEDURE do_listare
		Local lnOptiune, lnRecno
		Local laStructura[1]
		*:Global olucrare
		If Reccount("crslucrari") > 0
			lnRecno = Recno('crsLucrari')
		
			*!*		Private pcDataOra	&&	modificare	v 2.0.11
			lnOptiune = xmenu('\<Centralizator lucrari;\<Detalii lucrare')
			Do Case
				Case lnOptiune = 1
					*!*	modificare v 2.0.11
					*!*			pcDataOra = get_ora(2)
					*!*	*!*			This.AlwaysOnTop=.F.
					*!*			Select crslucrari
					*!*			Keyboard "{CTRL+F10}"
					*!*			Report Form centralizator_lucrari To Printer Prompt Preview
					*!*	*!*			This.AlwaysOnTop=.T.
					goExport.export2frx([crslucrari], [centralizator_lucrari], , , , , , .T.)
					*!*	modificare v 2.0.11	^
				Case lnOptiune = 2
					If Reccount('crslucrarielemente') = 0
						amessagebox("Nu exista elemente pe aceasta lucrare!", 0 + 48, "Atentie")
						Return
					Endif
					*!*			pcDataOra = get_ora(2)	&&	modificare v 2.0.11
					Select crslucrari
					Scatter Name olucrare
					*!*			This.AlwaysOnTop=.F.
					Select crslucrarielemente
					*!*	modificare v 2.0.2
					Dimension laStructura(1, 18)
					Afields(laStructura, [crslucrarielemente])
					Create Cursor crsbcklistare From Array laStructura
					Select * From crslucrarielemente Order By codmat Into Cursor crsbcklistare
					Select crsbcklistare
					*!*	modificare v 2.0.2	^
					*!*	modificare v 2.0.11
					goExport.export2frx([crsbcklistare], [detalii_lucrare], , , , , , .T.)
					*!*			Keyboard "{CTRL+F10}"
					*!*			Report Form detalii_lucrare To Printer Prompt Preview
					*!*	modificare v 2.0.11	^
					Release olucrare, laStructura
					*!*	modificare v 2.0.2
					Use In crsbcklistare
					*!*	modificare v 2.0.2	^
					*!*			This.AlwaysOnTop=.T.
				Otherwise
					Return
			Endcase
		
			Select crslucrari
			Try
				Goto m.lnRecno
			Catch
				Go Top
			Endtry
		
		Else
			amessagebox("Nu exista inregistrari in selectie!", 0 + 48, "Atentie")
		Endif
		This._grdrow1.SetFocus()
		
	ENDPROC

	PROCEDURE do_modifica
		If Reccount('crslucrari')>0
			Select crslucrari
			Scatter Name loRec
			Do Case
			Case loRec.inchisa=1
				amessagebox("Aceasta lucrare este inchisa si nu mai poate fi modificata!",0+48,"Atentie")
			Case loRec.executata=1
				amessagebox("Aceasta lucrare a fost executata si nu mai poate fi modificata!",0+48,"Atentie")
			Otherwise
				Private pniesire
				pniesire=0
				Do Adauga_Modifica_Inregistrare With "lucrari_detalii",loRec,loRec.id_lucrare,"UPDATE"
				If pniesire=1
					This.actualizeaza_grid1()
					Select crslucrari
					Locate For data_lucrare=loRec.data_lucrare And nrord=loRec.nrord
					This._grdrow1.SetFocus()
				Endif
			Endcase
		Endif
		
	ENDPROC

	PROCEDURE do_reset
		*!*	This.ck_nrord.Value=0
		*!*	This.ck_explicatie.Value=0
		*!*	This.ck_data_lucrare.Value=0
		*!*	This.ck_termen_executie.Value=0
		*!*	This.optinchise.Value=This.optinchise.ndefault
		*!*	This.optexecutate.Value=This.optexecutate.ndefault
		*!*	This.ck_nrord.SetFocus()
		
		THIS.filtru_pretty = ""
		THIS.filtru_pretty_ro = ""
		THIS.filtru_pretty_ro_full = ""
		IF TYPE("this.but_start_criterii1") = 'O'
			THIS.but_start_criterii1.TOOLTIPTEXT=THIS.filtru_pretty_ro
			THIS.but_start_criterii1.SETFOCUS
			THIS.but_start_criterii1.pornit = "nu"
		ENDIF 	
		THIS.do_cauta()
		THIS.REFRESH
	ENDPROC

	PROCEDURE do_sterge
		LOCAL loRec
		
		If Reccount('crslucrari')>0
			Select crslucrari
			Scatter Name loRec
			Do Case
			Case loRec.inchisa=1
				amessagebox("Aceasta lucrare este inchisa si nu mai poate fi stearsa!",0+48,"Atentie")
			Case loRec.executata=1
				amessagebox("Aceasta lucrare a fost executata si nu mai poate fi stearsa!",0+48,"Atentie")
			Otherwise
				Private pniesire
				* Local loRec
				pniesire=0
				Do STERGE_INREGISTRARE With "lucrari_detalii",loRec.id_lucrare
				If pniesire=1
					This.actualizeaza_grid1()
				Endif
			Endcase
		Endif
		
	ENDPROC

	PROCEDURE Init
		gcAcces=[1;2;3;4;]
		DoDefault()
	ENDPROC

	PROCEDURE But_reset_criterii1.Click
		LOCAL lcFiltru
		
		THIS.Parent.filtru_pretty = ""
		THIS.Parent.filtru_pretty_ro = ""
		THIS.Parent.filtru_pretty_ro_full = ""
		IF TYPE("this.but_start_criterii1") = 'O'
			THIS.Parent.but_start_criterii1.TOOLTIPTEXT=THIS.Parent.filtru_pretty_ro
			THIS.Parent.but_start_criterii1.SETFOCUS
			THIS.Parent.but_start_criterii1.pornit = "nu"
		ENDIF 	
		
		lcfiltru = [Stare executat;nofiled;1;|Stare deschis;nofiled;1;]
		This.Parent.but_start_criterii1.loadfiltru("")
		This.Parent.but_start_criterii1.loadfiltru(m.lcFiltru)
		THIS.Parent.REFRESH
	ENDPROC

	PROCEDURE But_start_criterii1.loadcriterii
		PARAMETERS tacriterii
		EXTERNAL ARRAY tacriterii
		#DEFINE crlf CHR(13)+CHR(10)
		
		lcStringCriterii="Data lucrare\data_lucrare\D\none\" + crlf + ;
			"Nr. lucrare\nrord\T\id_lucrare\nom_lucrare" + crlf + ;
			"Explicatie\explicatie\T\none\"+ crlf + ;	
			"Termen executie\termen_executie\D\none\" + crlf + ;
			"Stare executat\nofiled\A\Neexecutate,Executate,Toate#executata=0,executata=1,1=1\" + crlf + ;
			"Stare deschis\nofiled\A\Deschise,Inchise,Toate#inchisa=0,inchisa=1,1=1\"
		
		DODEFAULT()
		
	ENDPROC

	PROCEDURE _grdrow1.AfterRowColChange
		Lparameters nColIndex
		DoDefault()
		If This.RowColChange <> 2
			lcFiltru=[id_lucrare=]+Alltrim(Str(crslucrari.id_lucrare))
			This.Parent.actualizeaza_grid2(lcFiltru)
			This.Parent.actualizeaza_grid3(lcFiltru)
		Endif
		
	ENDPROC

	PROCEDURE _grdrow1.Init
		* Nu sterge se suprascrie cu Arial Narrow
	ENDPROC

	PROCEDURE _grdrow2.Init
		* Nu sterge se suprascrie cu Arial Narrow
	ENDPROC

	PROCEDURE _grdrow3.Init
		* Nu sterge se suprascrie cu Arial Narrow
	ENDPROC

ENDDEFINE

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

	*<PropValue>
		Name = "cus_odata_comenzi"
	*</PropValue>
	
	PROCEDURE make_sql
		Lparameters toRec,tnId
		
		Local lcActiune, lcIdNume, lcDataLivrare
		lcActiune = Alltrim(This.cActiune)
		
		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')
			lcNrComanda=Alltrim(toRec.nr_comanda)
			lcDataComanda=Alltrim(Ttoc(toRec.data_comanda,1))
			lcInterna=Alltrim(Str(toRec.interna))
			lnProcDiscount = Alltrim(Str(toRec.proc_discount,10,2))
		
			If Pemstatus(toRec,"ID_Facturare",4)
				lcAdresaFacturare=Iif(!(Isnull(toRec.ID_Facturare)Or Empty(toRec.ID_Facturare)),Alltrim(Str(toRec.ID_Facturare)),"NULL")
			Else
				lcAdresaFacturare="NULL"
			Endif
		
			If Pemstatus(toRec,"ID_Livrare",4)
				lcAdresaLivrare=Iif(!(Isnull(toRec.ID_Livrare)Or Empty(toRec.ID_Livrare)),Alltrim(Str(toRec.ID_Livrare)),"NULL")
			Else
				lcAdresaLivrare=""
			Endif
		
			If Pemstatus(toRec,"id_codclient",4)
				If (!Isnull(toRec.id_codclient) and  !Empty(toRec.id_codclient)) 
					lcid_codclient=Alltrim(TRANSFORM(toRec.id_codclient))
				Else
					lcid_codclient="NULL"
				Endif
			Else
				lcid_codclient="NULL"
			Endif
		
			If Pemstatus(toRec,"COMANDA_EXTERNA",4)
				lcCOMANDA_EXTERNA=Alltrim(Nvl(toRec.COMANDA_EXTERNA,""))
			Else
				lcCOMANDA_EXTERNA=""
			Endif
		
			lcIdCtr = [NULL]
		
			Do Case
				Case toRec.interna=1
					lcIdNume=[NULL]
					lcDataLivrare=[']+Alltrim(Ttoc(toRec.data_livrare,1))+[']
				Case toRec.interna=2
					lcIdNume=Alltrim(Str(toRec.id_part))
					lcDataLivrare=[']+Alltrim(Ttoc(toRec.data_livrare,1))+[']
				Case toRec.interna = 3
					lcIdNume=Alltrim(Str(toRec.id_gestiune))
					lcDataLivrare=[']+Alltrim(Ttoc(toRec.data_livrare,1))+[']
				Case toRec.interna = 4
					lcIdNume=Alltrim(Str(toRec.id_sectie2))
					lcDataLivrare=[']+Alltrim(Ttoc(toRec.data_livrare,1))+[']
		*!*	modificare	v 2.0.20
				Case toRec.interna=5
					lcIdNume=Alltrim(Str(toRec.id_part))
					lcDataLivrare=[']+Alltrim(Ttoc(toRec.data_livrare,1))+[']
					lcIdCtr = ALLTRIM(STR(toRec.id_ctr))
		*!*	modificare	v 2.0.20	^
			Endcase
		Endif
		Do Case
			Case lcActiune = "INSERT"
				lcSql = [begin pack_comenzi.adauga_comanda('] + lcNrComanda + [',to_date('] + lcDataComanda + [','YYYYMMDDHH24miss'),] +;
					lcIdNume + [,to_date(] + lcDataLivrare + [,'YYYYMMDDHH24miss'),] + lnProcDiscount + [,] + lcInterna + [,] + Alltrim(Str(gnIdUtil)) + [,]+Alltrim(Str(gnId_sectie)) + [,] +lcAdresaFacturare+[,]+lcAdresaLivrare +;
					[,] + lcid_codclient + [,'] + lcCOMANDA_EXTERNA + [',] + lcIdCtr + [); end;]
			Case lcActiune = "UPDATE"
				lcSql = [begin pack_comenzi.modifica_comanda(] + lcId + [,'] + lcNrComanda + [',to_date('] + lcDataComanda + [','YYYYMMDDHH24miss'),] +;
					lcIdNume + [,to_date(] + lcDataLivrare + [,'YYYYMMDDHH24miss'),] + lnProcDiscount + [,] + lcInterna + [,] + Alltrim(Str(gnIdUtil)) + [,] +lcAdresaFacturare+[,] +;
					lcAdresaLivrare + [,] + lcid_codclient + [,'] + lcCOMANDA_EXTERNA + [',] + lcIdCtr + [); end;]
			Case lcActiune = "DELETE"
				lcSql = [begin pack_comenzi.sterge_comanda(] + lcId + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		
		Endcase
		This.csql = lcSql
		
	ENDPROC

ENDDEFINE

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

	*<PropValue>
		Name = "cus_odata_lucrari_detalii"
	*</PropValue>
	
	PROCEDURE make_sql
		Lparameters toRec,tnId
		
		lcActiune = Alltrim(This.cActiune)
		
		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')
			lcNrord=Alltrim(toRec.nrord)
			lcDataLucrare=Alltrim(Ttoc(toRec.data_lucrare,1))
			lcExplicatie=Alltrim(NVL(toRec.explicatie,[]))
			lcTermenExecutie=Alltrim(Ttoc(toRec.termen_executie,1))
		Endif
		
		Do Case
		Case lcActiune = "INSERT"
			lcSql = [begin pack_comenzi.adauga_lucrare('] + lcNrord + [',to_date('] + lcDataLucrare + [','YYYYMMDDHH24miss'),] +;
				['] + lcExplicatie + [',to_date('] + lcTermenExecutie + [','YYYYMMDDHH24miss'),] + Alltrim(Str(gnIdUtil)) + [,]+ALLTRIM(STR(gnId_sectie))+[); end;]
		
		Case lcActiune = "UPDATE"
			lcSql = [begin pack_comenzi.modifica_lucrare(] + lcId + [,'] + lcNrord + [',to_date('] + lcDataLucrare + [','YYYYMMDDHH24miss'),] +;
				['] + lcExplicatie + [',to_date('] + lcTermenExecutie + [','YYYYMMDDHH24miss'),] + Alltrim(Str(gnIdUtil)) + [); end;]
		
		Case lcActiune = "DELETE"
			lcSql = [begin pack_comenzi.sterge_lucrare(] + lcId + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		
		Endcase
		This.csql = lcSql
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_articol_comanda 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_articol" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_codmat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_pret" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_um" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_cantitate" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_valoare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_explicatie_pret" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: nid
		*p: nnivelmodificare		&& - 1 daca utilizatorul are voie sa modifice toate datele ; 0 daca are voie sa modifice doar nr. de telefon
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 254
		Name = "frm_articol_comanda"
		nnivelmodificare = -1
		Width = 338
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 340
		_shape2.Height = 29
		_shape2.Left = 270
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 69
		Lb_titlu_alb_b121.Caption = "ADĂUGARE ARTICOL"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 9
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 306
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 7
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 30
		Gridsort1.Name = "Gridsort1"
	*</PropValue>

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Height = 27, ;
		Left = 274, ;
		Name = "But_renunt1", ;
		TabIndex = 8, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'clb_articol' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "clb_articol", ;
		TabIndex = 2, ;
		TabStop = .F., ;
		Top = 76, ;
		Text_simplu1.ControlSource = "poArticol.nume_articol", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Lb_simplu1.Caption = "Articol", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_cantitate' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "clb_cantitate", ;
		TabIndex = 4, ;
		Top = 132, ;
		Width = 290, ;
		TEXT_SIMPLU1.Alignment = 1, ;
		TEXT_SIMPLU1.ControlSource = "poArticol.cantitate", ;
		TEXT_SIMPLU1.InputMask = (get_mask(14,gnPcant)), ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		LB_SIMPLU1.Caption = "Cantitate", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_codmat' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "clb_codmat", ;
		TabIndex = 1, ;
		TabStop = .F., ;
		Top = 48, ;
		TEXT_SIMPLU1.ControlSource = "poArticol.codmat", ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.ReadOnly = .T., ;
		LB_SIMPLU1.Caption = "Cod material", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_pret' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "clb_pret", ;
		TabIndex = 5, ;
		Top = 160, ;
		Width = 290, ;
		TEXT_SIMPLU1.Alignment = 1, ;
		TEXT_SIMPLU1.ControlSource = "poArticol.pret", ;
		TEXT_SIMPLU1.InputMask = (get_mask(14,gnPPretV)), ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.ReadOnly = .F., ;
		LB_SIMPLU1.Caption = "Preț", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_um' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "clb_um", ;
		TabIndex = 3, ;
		TabStop = .F., ;
		Top = 104, ;
		Width = 290, ;
		TEXT_SIMPLU1.Alignment = 1, ;
		TEXT_SIMPLU1.ControlSource = "poArticol.um", ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.ReadOnly = .T., ;
		LB_SIMPLU1.Caption = "U.M.", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_valoare' AS clb_tx_simplu WITH ;
		Left = 24, ;
		Name = "Clb_valoare", ;
		TabIndex = 6, ;
		TabStop = .F., ;
		Top = 188, ;
		Width = 290, ;
		TEXT_SIMPLU1.Alignment = 1, ;
		TEXT_SIMPLU1.InputMask = (get_mask(14,gnPa)), ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.ReadOnly = .T., ;
		TEXT_SIMPLU1.Value = 0, ;
		LB_SIMPLU1.Caption = "Valoare", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'lb_explicatie_pret' AS _lbbase WITH ;
		Alignment = 1, ;
		AutoSize = .F., ;
		Caption = "Pretul și valoarea sunt cu/fără TVA.", ;
		Height = 17, ;
		Left = 24, ;
		Name = "lb_explicatie_pret", ;
		TabIndex = 10, ;
		Top = 226, ;
		Width = 288
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />
	
	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 poArticol.cantitate <= 0
				aMessagebox("Cantitatea trebuie sa fie mai mare decat 0!",0+48,"Atentie")
				Thisform.clb_cantitate.SetFocus()
				plReturn=.F.
			Case poArticol.Pret = 0
				If aMessagebox("Pretul de vanzare este 0!" + Chr(13) + Chr(10) + "Doriti sa continuati?" + Chr(13) + Chr(10) + Chr(13) + Chr(10) + "Pretul articolului se poate modifica din 'Politici de preturi si tarife'." ,4+32,'Comanda')	<> 6
					plReturn=.F.
				Else
					plReturn=.T.
				Endif
			Otherwise
				plReturn=.T.
		Endcase
		
		Return plReturn
		
	ENDPROC

	PROCEDURE Init
		Local lcExplicatie, llSuprascriePret
		DoDefault()
		*!* arat pretul cu rosu daca este <= 0
		This.clb_pret.text_simplu1.ForeColor = Iif(poArticol.Pret > 0, Rgb(0, 0, 0), Rgb(255, 0, 0))
		If poArticol.pret_cu_tva = 1
			lcExplicatie = [Prețul și valoarea afișate conțin TVA.]
		Else
			lcExplicatie = [Prețul și valoarea afișate nu conțin TVA.]
		Endif
		Thisform.lb_explicatie_pret.Caption = lcExplicatie
		
		llSuprascriePret = Iif(Type('gnSuprascriePretComanda') = 'N', m.gnSuprascriePretComanda = 1, .F.)
		This.clb_pret.text_simplu1.ReadOnly = !m.llSuprascriePret
		This.clb_pret.text_simplu1.TabStop = m.llSuprascriePret
	ENDPROC

	PROCEDURE clb_cantitate.TEXT_SIMPLU1.InteractiveChange
		lcval=This.ControlSource
		&lcval=This.Value
		Thisform.clb_valoare.teXT_SIMPLU1.Value=Round(poArticol.Pret*poArticol.cantitate,gnPc)
		Thisform.clb_valoare.teXT_SIMPLU1.Refresh()
		
	ENDPROC

	PROCEDURE clb_pret.TEXT_SIMPLU1.InteractiveChange
		lcval=This.ControlSource
		&lcval=This.Value
		Thisform.clb_valoare.teXT_SIMPLU1.Value=Round(poArticol.Pret*poArticol.cantitate,gnPc)
		Thisform.clb_valoare.teXT_SIMPLU1.Refresh()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_comenzi_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="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_data_comanda" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_data_livrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cArticol.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cArticol.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cValoare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cValoare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cPret.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cPret.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cCantitate.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cCantitate.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cPret_cu_tva.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cPret_cu_tva._checkbox1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cCodBare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_comanda_curenta.cCodBare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_urmator1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_precedent1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_comanda" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtArticoleLista" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_nr_comanda" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="CUS_ODATA_COMENZI1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_total" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_nume" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_interna" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmb_AdresaFacturare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_AdresadeFacturare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_AdresadeLivrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmb_AdresaLivrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmb_CodClient" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lbl_codclient" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cArticol.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cArticol.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cUM.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cUM.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cCodmat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cCodmat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cPret.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cPret.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cStoc.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cStoc.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cCodBare.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_articole_politica.cCodBare.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_articole" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtArticole" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ct_articole" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_reset1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_tx_simplu2._lbbase2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_contract" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkStoc" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: arataadrese
		*m: arata_coduri_clienti
		*m: arata_date
		*m: do_alege_client
		*m: do_alege_gestiune
		*m: do_alege_sectie
		*m: do_calculeaza_total
		*m: do_cauta_contract
		*m: do_creeaza_filtru
		*m: do_scrie_articole
		*m: showadresafacturarelivrare
		*m: show_cod_client
		*p: cnewvalue
		*p: cnume_val		&& Numele valutei alese.
		*p: coldvalue
		*p: lcomandamodificata		&& .T. daca au fost modificate articolele sau cantitatile articolelor de pe comanda.
		*p: lmodificare		&& .T. daca poate sa faca modificari.
		*p: ncantitate_init		&& Cantitatea initiala la intrarea in coloana "Cantitate".
		*p: ncritdenumire
		*p: nid
		*p: npret_init		&& Pret initial la intrarea in coloana "Pret"
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		cgridsortlist = grd_articole_politica,grd_comanda_curenta
		cnewvalue = 
		cnume_val = 
		coldvalue = 
		DoCreate = .T.
		Height = 586
		lcomandamodificata = .F.
		lmodificare = .T.
		Name = "frm_comenzi_nou"
		ncantitate_init = 0
		ncritdenumire = 1
		npret_init = 0
		Width = 800
		_memberdata = <VFPData>
			<memberdata name="ncritdenumire" display="ncritDenumire"/>
		</VFPData>
		_shape1.Anchor = 10
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 803
		_shape2.Height = 29
		_shape2.Left = 736
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 69
		Lb_titlu_alb_b121.Caption = "COMANDĂ"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 25
		BUT_TERMIN1.Anchor = 8
		BUT_TERMIN1.Height = 27
		BUT_TERMIN1.Left = 769
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 20
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.Width = 30
		Gridsort1.Left = 9
		Gridsort1.Name = "Gridsort1"
		Gridsort1.Top = 38
	*</PropValue>

	ADD OBJECT 'But_precedent1' AS but_precedent WITH ;
		Anchor = 8, ;
		Left = 314, ;
		Name = "But_precedent1", ;
		TabIndex = 19, ;
		ToolTipText = "Sterge articol de pe comanda", ;
		Top = 302
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Anchor = 8, ;
		Height = 27, ;
		Left = 739, ;
		Name = "But_renunt1", ;
		TabIndex = 21, ;
		Top = 1, ;
		Width = 30
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_reset1' AS but_reset WITH ;
		Anchor = 8, ;
		Left = 314, ;
		Name = "But_reset1", ;
		TabIndex = 31, ;
		Top = 200
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'But_urmator1' AS but_urmator WITH ;
		Anchor = 8, ;
		Left = 314, ;
		Name = "But_urmator1", ;
		TabIndex = 17, ;
		ToolTipText = "Adauga articol pe comanda", ;
		Top = 265
		*< END OBJECT: ClassLib="cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'chkStoc' AS _checkbox WITH ;
		Alignment = 0, ;
		Caption = "Articolele cu stoc", ;
		Left = 17, ;
		Name = "chkStoc", ;
		TabStop = .F., ;
		Top = 227
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'clb_data_comanda' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 12, ;
		Name = "clb_data_comanda", ;
		TabIndex = 3, ;
		Top = 89, ;
		Width = 302, ;
		TEXT_SIMPLU1.ControlSource = "porec.data_comanda", ;
		TEXT_SIMPLU1.Left = 114, ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.Top = 3, ;
		LB_SIMPLU1.Caption = "Dată comandă", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_data_livrare' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 12, ;
		Name = "clb_data_livrare", ;
		TabIndex = 5, ;
		Top = 145, ;
		Width = 302, ;
		TEXT_SIMPLU1.ControlSource = "porec.data_livrare", ;
		TEXT_SIMPLU1.Left = 114, ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.Top = 3, ;
		LB_SIMPLU1.Caption = "Dată livrare", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_nr_comanda' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 12, ;
		Name = "clb_nr_comanda", ;
		TabIndex = 2, ;
		TabStop = .F., ;
		Top = 61, ;
		Width = 302, ;
		TEXT_SIMPLU1.ControlSource = "porec.nr_comanda", ;
		TEXT_SIMPLU1.Left = 114, ;
		TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		TEXT_SIMPLU1.ReadOnly = .T., ;
		TEXT_SIMPLU1.Top = 3, ;
		LB_SIMPLU1.Caption = "Număr comandă", ;
		LB_SIMPLU1.Name = "LB_SIMPLU1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu1' AS clb_tx_simplu WITH ;
		Height = 29, ;
		Left = 361, ;
		Name = "Clb_tx_simplu1", ;
		TabIndex = 6, ;
		Top = 37, ;
		Width = 322, ;
		Text_simplu1.ControlSource = "porec.COMANDA_EXTERNA", ;
		Text_simplu1.Left = 125, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 3, ;
		Lb_simplu1.Caption = "Comandă externă", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu2' AS clb_tx_simplu WITH ;
		Height = 48, ;
		Left = 693, ;
		Name = "Clb_tx_simplu2", ;
		TabIndex = 11, ;
		Top = 37, ;
		Width = 90, ;
		Text_simplu1.ControlSource = "porec.proc_discount", ;
		Text_simplu1.Height = 23, ;
		Text_simplu1.InputMask = (get_mask(5,2)), ;
		Text_simplu1.Left = 7, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.Top = 22, ;
		Text_simplu1.Width = 53, ;
		Lb_simplu1.Caption = "Proc. discount", ;
		Lb_simplu1.Left = 3, ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.Top = 6
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_tx_simplu2._lbbase2' AS _lbbase WITH ;
		Caption = "%", ;
		Left = 65, ;
		Name = "_lbbase2", ;
		Top = 25
		*< END OBJECT: ClassLib="_lb_base.vcx" BaseClass="label" />

	ADD OBJECT 'Clb_tx_total' AS clb_tx_simplu WITH ;
		Anchor = 12, ;
		Height = 29, ;
		Left = 483, ;
		Name = "Clb_tx_total", ;
		TabIndex = 27, ;
		TabStop = .F., ;
		Top = 548, ;
		Width = 306, ;
		Text_simplu1.Alignment = 3, ;
		Text_simplu1.InputMask = (get_mask(14,gnPc)), ;
		Text_simplu1.Left = 117, ;
		Text_simplu1.Name = "Text_simplu1", ;
		Text_simplu1.ReadOnly = .T., ;
		Text_simplu1.Top = 3, ;
		Text_simplu1.Value = 0, ;
		Lb_simplu1.Caption = "Total comandă", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'cmb_AdresaFacturare' AS combobox WITH ;
		BoundColumn = 1, ;
		BoundTo = .F., ;
		ControlSource = "", ;
		FontSize = 10, ;
		Height = 24, ;
		Left = 481, ;
		Name = "cmb_AdresaFacturare", ;
		RowSourceType = 6, ;
		Style = 2, ;
		TabIndex = 9, ;
		Top = 120, ;
		Visible = .F., ;
		Width = 309
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cmb_AdresaLivrare' AS combobox WITH ;
		ControlSource = "", ;
		FontSize = 10, ;
		Height = 24, ;
		Left = 481, ;
		Name = "cmb_AdresaLivrare", ;
		Style = 2, ;
		TabIndex = 10, ;
		Top = 145, ;
		Visible = .F., ;
		Width = 309
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cmb_CodClient' AS combobox WITH ;
		ColumnCount = 3, ;
		ColumnLines = .F., ;
		ColumnWidths = "200,0,0", ;
		ControlSource = "", ;
		FontSize = 10, ;
		Height = 24, ;
		Left = 481, ;
		Name = "cmb_CodClient", ;
		Style = 2, ;
		TabIndex = 8, ;
		Top = 95, ;
		Visible = .F., ;
		Width = 200
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'ct_articole' AS criteriu_text WITH ;
		Height = 24, ;
		Left = 90, ;
		Name = "ct_articole", ;
		TabIndex = 12, ;
		Top = 200, ;
		Value = 2, ;
		Width = 84
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="combobox" />

	ADD OBJECT 'Ct_contract' AS ct_clb_cautare_var WITH ;
		cconditie = EMPTY(NVL(poRec.id_ctr,0)), ;
		cprocedura = Thisform.do_cauta_contract, ;
		cvar_afisata = porec.numar_contract, ;
		Height = 31, ;
		Left = 360, ;
		Name = "Ct_contract", ;
		TabIndex = 7, ;
		Top = 64, ;
		Visible = .F., ;
		Width = 324, ;
		shape_cautare.Height = 29, ;
		shape_cautare.Left = 1, ;
		shape_cautare.Name = "shape_cautare", ;
		shape_cautare.Top = 1, ;
		shape_cautare.Width = 291, ;
		img_cautare.Left = 298, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 5, ;
		lb_cautare.Caption = "Contract", ;
		lb_cautare.Left = 10, ;
		lb_cautare.Name = "lb_cautare", ;
		lb_cautare.Top = 8, ;
		tx_cautare.Height = 23, ;
		tx_cautare.Left = 127, ;
		tx_cautare.Name = "tx_cautare", ;
		tx_cautare.Top = 4, ;
		tx_cautare.Width = 159
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_nume' AS ct_clb_cautare WITH ;
		cconditie = , ;
		cvar_afisata = porec.nume, ;
		Height = 31, ;
		Left = 11, ;
		Name = "Ct_nume", ;
		TabIndex = 4, ;
		Top = 116, ;
		Visible = .F., ;
		Width = 337, ;
		img_cautare.Left = 307, ;
		img_cautare.Name = "img_cautare", ;
		img_cautare.Top = 5, ;
		clb_tx_cautare.Lb_simplu1.Caption = "Nume client", ;
		clb_tx_cautare.Lb_simplu1.Left = 8, ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Left = 1, ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Left = 114, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Top = 1, ;
		clb_tx_cautare.Width = 302
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'CUS_ODATA_COMENZI1' AS cus_odata_comenzi WITH ;
		Left = 660, ;
		Name = "CUS_ODATA_COMENZI1", ;
		Top = 180
		*< END OBJECT: ClassLib="ocomenzi.vcx" BaseClass="custom" />

	ADD OBJECT 'grd_articole_politica' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 6, ;
		DeleteMark = .F., ;
		Height = 324, ;
		HighlightStyle = 2, ;
		Left = 17, ;
		Name = "grd_articole_politica", ;
		Panel = 1, ;
		RecordSource = "v_articole", ;
		RowHeight = 19, ;
		TabIndex = 16, ;
		Top = 252, ;
		Width = 296, ;
		Column1.ColumnOrder = 2, ;
		Column1.ControlSource = "nume_articol", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cArticol", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 185, ;
		Column2.ColumnOrder = 4, ;
		Column2.ControlSource = "um", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.Name = "cUM", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 74, ;
		Column3.ColumnOrder = 1, ;
		Column3.ControlSource = "codmat", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.Name = "cCodmat", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 90, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "pret", ;
		Column4.DynamicForeColor = "IIF(pret > 0, RGB(0,0,0), RGB(255,0,0))", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPPretV)), ;
		Column4.Name = "cPret", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 74, ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "stoc", ;
		Column5.Format = "RK", ;
		Column5.InputMask = (get_mask(14,gnPcant)), ;
		Column5.Name = "cStoc", ;
		Column5.ReadOnly = .T., ;
		Column6.ColumnOrder = 3, ;
		Column6.ControlSource = "codbare", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cCodBare", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 115
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_articole_politica.cArticol.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Articol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_articole_politica.cArticol.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

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

	ADD OBJECT 'grd_articole_politica.cCodBare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_articole_politica.cCodmat.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cod material", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_articole_politica.cCodmat.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_articole_politica.cPret.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_articole_politica.cPret.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_articole_politica.cStoc.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Stoc", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

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

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

	ADD OBJECT 'grd_articole_politica.cUM.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_comanda_curenta' AS _grdrow WITH ;
		Anchor = 13, ;
		ColumnCount = 6, ;
		DeleteMark = .F., ;
		Height = 288, ;
		HighlightStyle = 2, ;
		Left = 346, ;
		Name = "grd_comanda_curenta", ;
		Panel = 1, ;
		RecordSource = "crscomanda_curenta", ;
		RowHeight = 19, ;
		TabIndex = 18, ;
		Top = 252, ;
		Width = 444, ;
		Column1.ColumnOrder = 1, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial", ;
		Column1.FontSize = 10, ;
		Column1.Name = "cArticol", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 208, ;
		Column2.ColumnOrder = 4, ;
		Column2.ControlSource = "valoare", ;
		Column2.FontName = "Arial", ;
		Column2.FontSize = 10, ;
		Column2.InputMask = (get_mask(14,gnPc)), ;
		Column2.Name = "cValoare", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 80, ;
		Column3.ColumnOrder = 3, ;
		Column3.ControlSource = "pret", ;
		Column3.FontName = "Arial", ;
		Column3.FontSize = 10, ;
		Column3.InputMask = (get_mask(14,gnPPretV)), ;
		Column3.Name = "cPret", ;
		Column3.Width = 62, ;
		Column4.ColumnOrder = 2, ;
		Column4.ControlSource = "cantitate", ;
		Column4.FontName = "Arial", ;
		Column4.FontSize = 10, ;
		Column4.InputMask = (get_mask(14,gnPcant)), ;
		Column4.Name = "cCantitate", ;
		Column4.ReadOnly = .T., ;
		Column4.Width = 59, ;
		Column5.ControlSource = "pret_cu_tva", ;
		Column5.FontName = "Arial", ;
		Column5.FontSize = 10, ;
		Column5.Name = "cPret_cu_tva", ;
		Column5.ReadOnly = .T., ;
		Column5.Sparse = .F., ;
		Column5.Width = 39, ;
		Column6.ControlSource = "codbare", ;
		Column6.FontSize = 10, ;
		Column6.Name = "cCodBare", ;
		Column6.ReadOnly = .T., ;
		Column6.Width = 124
		*< END OBJECT: ClassLib="_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_comanda_curenta.cArticol.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Articol", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_comanda_curenta.cArticol.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		Enabled = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_comanda_curenta.cCantitate.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cantitate", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_comanda_curenta.cCantitate.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

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

	ADD OBJECT 'grd_comanda_curenta.cCodBare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_comanda_curenta.cPret.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Pret", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_comanda_curenta.cPret.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .F., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'grd_comanda_curenta.cPret_cu_tva._checkbox1' AS _checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .F., ;
		Caption = "", ;
		Centered = .T., ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Left = 27, ;
		Name = "_checkbox1", ;
		ReadOnly = .T., ;
		Top = 35
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="checkbox" />

	ADD OBJECT 'grd_comanda_curenta.cPret_cu_tva.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Cu TVA", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_comanda_curenta.cValoare.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Valoare", ;
		FontName = "Arial", ;
		FontSize = 10, ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_comanda_curenta.cValoare.Text1' AS textbox WITH ;
		BackColor = 255,255,255, ;
		BorderStyle = 0, ;
		FontName = "Arial", ;
		FontSize = 10, ;
		ForeColor = 0,0,0, ;
		Margin = 0, ;
		Name = "Text1", ;
		ReadOnly = .T., ;
		SelectedBackColor = 100,185,255
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Gridextra1' AS gridextra WITH ;
		gridexpression = thisform.grd_articole_politica, ;
		Left = 6, ;
		Name = "Gridextra1", ;
		productname = ROA, ;
		Top = 304
		*< END OBJECT: ClassLib="..\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'Gridextra2' AS gridextra WITH ;
		gridexpression = thisform.grd_comanda_curenta, ;
		Left = 786, ;
		Name = "Gridextra2", ;
		productname = ROA, ;
		Top = 253
		*< END OBJECT: ClassLib="..\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'lb_articole' AS lb_simplu WITH ;
		Caption = "Articol/Cod", ;
		Left = 20, ;
		Name = "lb_articole", ;
		TabIndex = 23, ;
		Top = 204
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'lb_comanda' AS lb_simplu WITH ;
		Anchor = 8, ;
		Caption = "Articol comandă", ;
		Height = 18, ;
		Left = 353, ;
		Name = "lb_comanda", ;
		TabIndex = 26, ;
		Top = 205, ;
		Width = 96
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'lbl_AdresadeFacturare' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Adresa de facturare", ;
		FontSize = 10, ;
		Height = 18, ;
		Left = 362, ;
		Name = "lbl_AdresadeFacturare", ;
		TabIndex = 28, ;
		Top = 124, ;
		Visible = .F., ;
		Width = 115
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbl_AdresadeLivrare' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Adresa de livrare :", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 362, ;
		Name = "lbl_AdresadeLivrare", ;
		TabIndex = 29, ;
		Top = 149, ;
		Visible = .F., ;
		Width = 111
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lbl_codclient' AS label WITH ;
		BackStyle = 0, ;
		Caption = "Cod client :", ;
		FontSize = 10, ;
		Height = 17, ;
		Left = 362, ;
		Name = "lbl_codclient", ;
		TabIndex = 30, ;
		Top = 99, ;
		Visible = .F., ;
		Width = 96
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'opt_interna' AS combobox WITH ;
		ControlSource = "porec.interna", ;
		FontCharSet = 238, ;
		Height = 24, ;
		Left = 12, ;
		Name = "opt_interna", ;
		Style = 2, ;
		TabIndex = 1, ;
		Top = 37, ;
		Width = 302
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'txtArticole' AS textbox WITH ;
		Anchor = 10, ;
		FontSize = 10, ;
		Format = "!k", ;
		Height = 23, ;
		Left = 179, ;
		Name = "txtArticole", ;
		TabIndex = 13, ;
		ToolTipText = "Cautare dupa articol, cod material sau cod bare", ;
		Top = 201, ;
		Width = 131
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'txtArticoleLista' AS textbox WITH ;
		Anchor = 8, ;
		Format = "!k", ;
		Height = 23, ;
		Left = 453, ;
		Name = "txtArticoleLista", ;
		TabIndex = 24, ;
		ToolTipText = "Tastati primele litere pentru cautare articole in lista de preturi", ;
		Top = 203, ;
		Width = 237
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE arataadrese
		Local llRaspuns,llRaspuns2
		Store .F. To llRaspuns,llRaspuns2
		If !Empty(Nvl(poRec.id_part,0))
			lnid_part=poRec.id_part
			lnid_comanda=poRec.id_comanda
			*!*	modificare	v 2.0.27 : am adaugat sters = 0 si inactiv = 0
			CREATE CURSOR v_adrese (denumire_adresa V(250), strada V(200), id_adresa N(20))
			
			lcSql = [select SUBSTR(NVL(denumire_adresa, adresa), 1, 250) as denumire_adresa,strada,id_adresa from vadrese_parteneri where id_part=]+Transform(lnid_part)+[ and sters = 0 and inactiv = 0]
			lcCursor = [v_adrese]
			If goExecutor.oExecuta(lcSql,'v_adrese_temp')
				SELECT v_adrese
				APPEND FROM DBF('v_adrese_temp')
				USE IN (SELECT('v_adrese_temp'))
				
				Select v_adrese
				If Reccount(lcCursor)>0
					llRaspuns = .T.
					With Thisform.cmb_AdresaFacturare
						.ColumnCount=1
						.BoundColumn=3
						.BoundTo= .T.
						.RowSource=lcCursor
						.RowSourceType= 2
		*	.ControlSource="porec.ID_Facturare"
					Endwith
					With Thisform.cmb_AdresaLivrare
						.ColumnCount=1
						.BoundColumn=3
						.BoundTo= .T.
						.RowSource=lcCursor
						.RowSourceType= 2
		*		.ControlSource="porec.ID_Livrare"
					Endwith
		
					Thisform.showadresafacturarelivrare(.T.)
					lcSql = [select id_facturare,id_livrare from comenzi where sters=0 and id_comanda=]+Transform(lnid_comanda)
					lcCursor1 = [v_adrese_COMANDA]
					if goExecutor.oExecuta(lcSql,lcCursor1)
						If Reccount(lcCursor1)>0
							Select v_adrese_COMANDA
							Scatter Name porecob
							Thisform.cmb_AdresaFacturare.Value=porecob.id_facturare
							Thisform.cmb_AdresaLivrare.Value =porecob.id_livrare
							llRaspuns2 = .T.
						Endif
					Endif
					If !llRaspuns2
						Thisform.cmb_AdresaFacturare.Value=v_adrese.id_adresa
						Thisform.cmb_AdresaLivrare.Value =v_adrese.id_adresa
						poRec.id_livrare=v_adrese.id_adresa
						poRec.id_facturare=v_adrese.id_adresa
					Endif
				Endif
			Endif
		Endif
		If !llRaspuns
			Thisform.showadresafacturarelivrare(.F.)
		Endif
	ENDPROC

	PROCEDURE arata_coduri_clienti
		Local llRaspuns, llRaspuns2
		Store .F. To llRaspuns,llRaspuns2
		If !Empty(Nvl(poRec.id_part,0))
			lnid_part=poRec.id_part
			lnid_comanda=poRec.id_comanda
			lcSql = [select COD,ID_PART,ID from parteneri_coduri where id_part=]+Transform(lnid_part)
			lcCursor = [v_coduri]
			lnSucces = goExecutor.oExecute(lcSql,lcCursor)
			If lnSucces < 0
				amessagebox(goExecutor.cEroare,16,"Eroare")
			Else
				If Reccount(lcCursor)>0
					llRaspuns = .T.
					With Thisform.cmb_codclient
						.ColumnCount=3
						.BoundColumn=3
						.BoundTo= .T.
						.RowSource=lcCursor
						.RowSourceType= 2
					Endwith
					Thisform.show_cod_client(.T.)
					lcSql = [select id_codclient from comenzi where sters=0 and id_comanda=]+Transform(lnid_comanda)
					lcCursor1 = [v_codclient_comanda]
					lnSucces = goExecutor.oExecute(lcSql,lcCursor1)
					If lnSucces < 0
						amessagebox(goExecutor.cEroare,16,"Eroare")
					Else
						If Reccount(lcCursor1)>0
							llRaspuns2 = .T.
							Select v_codclient_comanda
							Scatter Name porecob
							Thisform.cmb_codclient.Value=porecob.id_codclient
						Endif
					Endif
					If !llRaspuns2
						Thisform.cmb_codclient.Value=v_coduri.Id
						poRec.id_codclient=v_coduri.Id
					Endif
				Endif
			Endif
		Endif
		If !llRaspuns
			Thisform.show_cod_client(.F.)
		Endif
		
	ENDPROC

	PROCEDURE arata_date
		*!*	modificare	v 2.0.10
		*!*	Lparameters tnValue
		Local lnValue
		*!*	lnValue = tnValue
		lnValue = Thisform.opt_interna.ListIndex
		*!*	modificare	v 2.0.10	^
		Do Case
		Case lnValue = 1
			Thisform.ct_nume.Visible = .F.
			Thisform.clb_data_livrare.Visible = .F.
			Thisform.clb_tx_simplu1.Visible = .F.	&&	modificare	v 2.0.20
			Thisform.ct_contract.Visible = .F.		&&	modificare	v 2.0.20	
		Case lnValue = 2
			With Thisform.ct_nume
				.Visible = .T.
				.cconditie = [EMPTY(NVL(poRec.nume,'')) AND EMPTY(NVL(poRec.id_part,0))]
				.cprocedura = [thisform.do_alege_client]
				.clb_tx_cautare.lb_simplu1.Caption = [Nume client]
			Endwith
			Thisform.clb_data_livrare.Visible = .T.
			Thisform.clb_tx_simplu1.Visible = .T.	&&	modificare	v 2.0.20
			Thisform.ct_contract.Visible = .F.		&&	modificare	v 2.0.20
		*!*	modificare	v 2.0.20
		Case lnValue = 5
			With Thisform.ct_nume
				.Visible = .T.
				.cconditie = [EMPTY(NVL(poRec.nume,'')) AND EMPTY(NVL(poRec.id_part,0))]
				.cprocedura = [thisform.do_alege_client]
				.clb_tx_cautare.lb_simplu1.Caption = [Nume client]
			Endwith
			Thisform.clb_data_livrare.Visible = .T.
			Thisform.clb_tx_simplu1.Visible = .T.
			Thisform.ct_contract.Visible = .T.	
		*!*	modificare	v 2.0.20	^	
		Case lnValue = 3
			With Thisform.ct_nume
				.Visible = .T.
				.cconditie = [EMPTY(NVL(poRec.nume,'')) AND EMPTY(NVL(poRec.id_gestiune,0))]
				.cprocedura = [thisform.do_alege_gestiune]
				.clb_tx_cautare.lb_simplu1.Caption = [Gestiune]
			Endwith
			Thisform.clb_data_livrare.Visible = .T.
			Thisform.clb_tx_simplu1.Visible = .F.	&&	modificare	v 2.0.20
			Thisform.ct_contract.Visible = .F.		&&	modificare	v 2.0.20
		Case lnValue = 4
			With Thisform.ct_nume
				.Visible = .T.
				.cconditie = [EMPTY(NVL(poRec.nume,'')) AND EMPTY(NVL(poRec.id_sectie,0))]
				.cprocedura = [thisform.do_alege_sectie]
				.clb_tx_cautare.lb_simplu1.Caption = [Secție]
			Endwith
			Thisform.clb_data_livrare.Visible = .T.
			Thisform.clb_tx_simplu1.Visible = .F.	&&	modificare	v 2.0.20
			Thisform.ct_contract.Visible = .F.		&&	modificare	v 2.0.20
		Endcase
		
	ENDPROC

	PROCEDURE Destroy
		If Used('v_articole')
			Use In v_articole
		Endif
		If Used('crscomanda_curenta')
			Use In crscomanda_curenta
		EndIf
		If Used('crssterse')
			Use in crssterse
		EndIf
	ENDPROC

	PROCEDURE do_adauga
		If Used('v_articole') And Reccount('v_articole')>0
			Private poArticol
			Select v_articole
			Scatter Name poArticol
		
			Select crscomanda_curenta
			Locate For id_articol = poArticol.id_articol
			If Found()
				Thisform.grd_comanda_curenta.SetFocus()
			Else
				gnButon=2
				AddProperty(poArticol,'cantitate',0)
		
				ofrmadarticol=Createobject("frm_articol_comanda")
				ofrmadarticol.Show(1)
				If gnButon=1 And !Empty(This.nId) And !Isnull(This.nId)
		*!*	modificare	v 2.0.4
		*!*				lcSql = [begin pack_comenzi.adauga_articol_comanda(] + Alltrim(Str(This.nId)) + [,] + Alltrim(Str(poArticol.id_articol)) + [,] + Alltrim(Str(poArticol.id_pol)) + [,] + ;
		*!*					ALLTRIM(Str(poArticol.cantitate,14,3)) + [,] + Alltrim(Str(gnIdUtil)) + [,]+ALLTRIM(STR(gnId_sectie))+[); end;]
		*!*				lnSucces = goExecutor.oExecute(lcSql)
		
		*!*				If lnSucces < 0
		*!*					aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
		*!*					Return
		*!*				Endif
		*!*	modificare	v 2.0.4	^
					Thisform.grd_comanda_curenta.salveaza_grid()
					Select crscomanda_curenta
					Append Blank
					*!*	modificare	v 2.0.26 : am adaugat pret_cu_tva
					Replace denumire With poArticol.nume_articol,cantitate With poArticol.cantitate,id_articol With poArticol.id_articol,;
						id_pol With poArticol.id_pol,Pret With poArticol.Pret,valoare With Round(poArticol.cantitate*poArticol.Pret,gnPc),;
						pret_cu_tva WITH poArticol.pret_cu_tva
					With Thisform.grd_comanda_curenta
						lnNrInregVizibile = Floor((.Height - .HeaderHeight)/.RowHeight)
					Endwith
					If lnNrInregVizibile < Recno('crscomanda_curenta')
						lnRecNo = Recno() - lnNrInregVizibile
						Go lnRecNo
					Else
						Go Top
					Endif
		*!*	modificare	v 2.0.24
					Thisform.lcomandamodificata = .T.
					Thisform.oRec.oBackupXML.SaveBackupSet("crscomanda_curenta")
		*!*	modificare	v 2.0.24	^		&&	modificare	v 2.0.24
					Thisform.grd_comanda_curenta.incarca_grid()
		
					Thisform.do_calculeaza_total()
		*!*				Thisform.grd_comanda_curenta.SetFocus()
				Endif
				Thisform.txtArticole.SetFocus()
			Endif
		
			Release ofrmadarticol, poArticol
		Endif
	ENDPROC

	PROCEDURE do_alege_client
		Local loCauta
		loCauta = CautPartenerContabilitate(GetHash([cTitlu=>Alegeți clientul??cCont=>4111??lAdaugCorespondente=>1]))
		If gnButon = 1 And !Empty(loCauta.id_part) And !Empty(loCauta.denumire)
			poRec.id_part = loCauta.id_part
			poRec.nume = Alltrim(loCauta.denumire)
			Thisform.arataadrese()
			Thisform.arata_coduri_clienti()
			If poRec.interna = 5 And !Empty(Nvl(poRec.data_comanda,{}))
				Private pnId,pcNumar
				pnId = 0
				pcNumar = []
				lcSql = [begin pack_comenzi.cauta_contract_comanda(?poRec.data_comanda,?poRec.id_part,?gnIdSucursala,?@pnId,?@pcNumar); end;]
				lnSucces = goExecutor.oExecute(lcSql)
				If lnSucces < 0
					amessagebox(goExecutor.cEroare,16,"Eroare")
				Else
					poRec.id_ctr = pnId
					poRec.numar_contract = pcNumar
					Thisform.ct_contract.tx_cautare.Refresh()
				Endif
				Release pnId,pcNumar
			Endif
			Thisform.clb_data_livrare.SetFocus()
		Else
			poRec.id_part = 0
			poRec.nume = []
		Endif
		
		
	ENDPROC

	PROCEDURE do_alege_gestiune
		Local loCauta
		loCauta = caut_gestiune()
		If !Empty(Nvl(loCauta.id_gestiune,0)) And !Empty(loCauta.nume_gestiune)
			poRec.id_gestiune = loCauta.id_gestiune
			poRec.nume = Alltrim(loCauta.nume_gestiune)
			Thisform.clb_data_livrare.SetFocus()
		Else
			poRec.id_gestiune = 0
			poRec.nume = []
		Endif
	ENDPROC

	PROCEDURE do_alege_sectie
		Local loCauta
		loCauta = caut_sectie()
		If !Empty(Nvl(loCauta.id_sectie,0)) And !Empty(loCauta.sectie)
			poRec.id_sectie2 = loCauta.id_sectie
			poRec.nume = Alltrim(loCauta.sectie)
			Thisform.clb_data_livrare.SetFocus()
		Else
			poRec.id_sectie2 = 0
			poRec.nume = []
		Endif
	ENDPROC

	PROCEDURE do_calculeaza_total
		*!*	modificare	v 2.0.4
		*!*	Select Nvl(Sum(valoare),0) As valoare From crscomanda_curenta Into Cursor crstempsuma
		Select Nvl(Sum(valoare),0) As valoare From crscomanda_curenta Into Cursor crstempsuma
		*!*	modificare	v 2.0.4	^
		Select crstempsuma
		lnTotal = valoare
		Thisform.clb_tx_total.text_simplu1.Value = lnTotal
		
		If Used('crstempsuma')
			Use In crstempsuma
		Endif
	ENDPROC

	PROCEDURE do_cauta_contract
		Local loCauta
		If Empty(Nvl(poRec.id_part,0))
			amessagebox("Nu ati ales clientul!",0+48,"Atentie")
			Thisform.ct_nume.SetFocus()
		Else
			loCauta = caut_contract_activ(-1,poRec.id_part,poRec.data_comanda)
			If gnButon <> 2
				poRec.id_ctr = loCauta.id_ctr
		*!*	modificare	v 2.0.23
		*!*			poRec.numar_contract = Alltrim(Str(loCauta.numar))+[/]+Day(loCauta.Data)+[.]+Month(loCauta.Data)+[.]+Year(loCauta.Data)
				poRec.numar_contract = Alltrim(loCauta.contract)
		*!*	modificare	v 2.0.23	^		
				Do Case
					Case This.cmb_CodClient.Visible
						This.cmb_CodClient.SetFocus()
					Case This.cmb_AdresaFacturare.Visible
						This.cmb_AdresaFacturare.SetFocus()
					Case This.cmb_AdresaLivrare.Visible
						This.cmb_AdresaLivrare.SetFocus()
					Otherwise
						This.clb_tx_simplu2.SetFocus()
				Endcase
			Endif
		Endif
		
	ENDPROC

	PROCEDURE do_creeaza_filtru
		Lparameters toCriteriu,tcNumeCamp,tcValoare
		Local lnCriteriu,lcFiltru
		lnCriteriu = toCriteriu.Value
		Do Case
		Case lnCriteriu = 1
			lcFiltru = "LIKE('" + Upper(Strtran(tcValoare,['],[''])) + "*',UPPER(Nvl("+Alltrim(tcNumeCamp)+",'')))"
		Case lnCriteriu = 2
			lcFiltru = "UPPER(Nvl("+Alltrim(tcNumeCamp)+",''))='" + Upper(Strtran(tcValoare,['],[''])) + "'"
		Case lnCriteriu = 3
			lcFiltru = "UPPER(Nvl("+Alltrim(tcNumeCamp)+",''))<>'" + Upper(Strtran(tcValoare,['],[''])) + "'"
		Case lnCriteriu = 4
			lcFiltru = "LIKE('*" + Upper(Strtran(tcValoare,['],[''])) + "*',UPPER(Nvl("+Alltrim(tcNumeCamp)+",'')))"
		Case lnCriteriu = 5
			lcFiltru = "!LIKE('*" + Upper(Strtran(tcValoare,['],[''])) + "*',UPPER(Nvl("+Alltrim(tcNumeCamp)+",'')))"
		Case lnCriteriu=6
			lcFiltru = "EMPTY(Nvl("+Alltrim(tcNumeCamp)+",''))"
		Case lnCriteriu=7
			lcFiltru = "!EMPTY(Nvl("+Alltrim(tcNumeCamp)+",''))"
		Endcase
		Return lcFiltru
	ENDPROC

	PROCEDURE do_modifica
		Lparameters tnCantitate
		SET STEP ON 
		*!*	Thisform.grd_comanda_curenta.salveaza_grid()
		Select crscomanda_curenta
		*!*	Replace cantitate With tnCantitate,valoare With Round(tnCantitate*Pret,gnPc),nrcrt With -99
		Replace valoare With Round(cantitate*Pret,gnPc),nrcrt With -99
		
		*!*	modificare	v 2.0.24
		Thisform.lcomandamodificata = .T.
		Thisform.oRec.oBackupXML.SaveBackupSet("crscomanda_curenta")
		*!*	modificare	v 2.0.24	^
		Thisform.do_calculeaza_total()
		*!*	Thisform.grd_comanda_curenta.incarca_grid()
	ENDPROC

	PROCEDURE do_precedent
		If !Empty(This.nId) And !Isnull(This.nId)
			Thisform.do_sterge()
		Endif
		
	ENDPROC

	PROCEDURE do_reset
		lcCriteriuDenumire = goExport.citesteSetareRegistru("CRITDENUMIRE")
		If !Empty(lcCriteriuDenumire) And Type('VAL(lcCriteriuDenumire)') = 'N'
			Thisform.ncritDenumire = Val(lcCriteriuDenumire)
		Endif
		Thisform.ct_articole.Value = Thisform.ncritDenumire
		Thisform.txtArticole.Value = []
		Select v_articole
		Set Filter To
		Go Top
		Thisform.grd_articole_politica.SetFocus()
		
	ENDPROC

	PROCEDURE do_scrie_articole
		Local llReturn
		Store .T. To llReturn
		*!*	modificare v 2.0.18 : am pus crssterse inainte de crscomanda_curenta pentru ca altfel imi da eroare cand vreau
		*!*  sa adaug un articol pe care l-am sters in aceeasi sesiune ( la adaugare il mai gasesc o data pe comanda )
		Select crssterse
		Scan
			lnId = id_c
			lcSql = [begin pack_comenzi.sterge_articol_comanda(] + Alltrim(Str(lnId)) + [,] + ;
				Alltrim(Str(gnIdUtil)) + [); end;]
			lnSucces = goExecutor.oExecute(lcSql)
			If lnSucces < 0
				aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
				llReturn = .F.
				Exit
			Endif
			Select crssterse
		Endscan
		If llReturn
			Select crscomanda_curenta
			Scan
				Scatter Name poArticol
				Do Case
					Case Empty(Nvl(poArticol.id_comanda_element,0))
						lcSql = [begin pack_comenzi.adauga_articol_comanda(] + Alltrim(Str(This.nId)) + [,] + ;
							Alltrim(Str(poArticol.id_articol)) + [,] + Alltrim(Str(poArticol.id_pol)) + [,] + ;
							ALLTRIM(Str(poArticol.cantitate,14,3)) + [,] + ;
							ALLTRIM(Str(poArticol.pret,14,4)) + [,] + ;
							Alltrim(Str(gnIdUtil)) + [,] + ;
							Alltrim(Str(gnId_sectie))+[); end;]
					Case poArticol.nrcrt = -99		&&	 a fost modificata comanda
						lcSql = [begin pack_comenzi.modifica_articol_comanda(] + Alltrim(Str(poArticol.id_comanda_element)) + [,] + ;
							ALLTRIM(Str(poArticol.cantitate,14,3)) + [,] + ;
							ALLTRIM(Str(poArticol.pret,14,4)) + [,] + ;
							Alltrim(Str(gnIdUtil)) + [); end;]
					Otherwise
						Loop
				Endcase
				lnSucces = goExecutor.oExecute(lcSql)
				If lnSucces < 0
					aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
					llReturn = .F.
					Exit
				Endif
				Select crscomanda_curenta
			Endscan
		Endif
		Return llReturn
	ENDPROC

	PROCEDURE do_sterge
		If !Empty(This.nid) And !Isnull(This.nid)
			If Reccount('crscomanda_curenta')>0
				Private poArticol
				Select crscomanda_curenta
				Scatter Name poArticol
				If aMESSAGEBOX("Doriti sa stergeti articolul "+Alltrim(poArticol.denumire)+" de pe comanda?",4+32,"Confirmare stergere")==6
		*!*	modificare	v 2.0.4
		*!*				lcSql = [begin pack_comenzi.sterge_articol_comanda(] + Alltrim(Str(This.nid)) + [,] + Alltrim(Str(poArticol.id_articol)) + [,] + ;
		*!*					ALLTRIM(Str(poArticol.id_pol)) + [,] + Alltrim(Str(gnIdUtil)) + [); end;]
		*!*				lnSucces = goExecutor.oExecute(lcSql)
		
		*!*				If lnSucces < 0
		*!*					aMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
		*!*					Return
		*!*				Endif
		*!*				save_grid_tag(Thisform.grd_comanda_curenta)
		*!*				Select * From crscomanda_curenta Where id_articol <> poArticol.id_articol Order By denumire ;
		*!*					INTO Cursor crscomanda_curenta Readwrite
		*!*				restore_grid_tag(Thisform.grd_comanda_curenta)
					Thisform.grd_comanda_curenta.salveaza_grid()
					If !Empty(Nvl(poArticol.id_comanda_element,0))
						Select crssterse
						Append Blank
						Replace id_c With poArticol.id_comanda_element
					Endif
					Select crscomanda_curenta
					Delete
		*!*	modificare	v 2.0.24
					Thisform.lcomandamodificata = .T.
					Thisform.oRec.oBackupXML.SaveBackupSet("crscomanda_curenta")
		*!*	modificare	v 2.0.24	^		&&	modificare	v 2.0.24
					Thisform.grd_comanda_curenta.incarca_grid()
		*!*	modificare	v 2.0.4	^
					Thisform.do_calculeaza_total()
		
					Thisform.grd_comanda_curenta.SetFocus()
				Endif
			Endif
			Release poArticol
		Endif
		
	ENDPROC

	PROCEDURE do_urmator
		If !Empty(This.nId) And !Isnull(This.nId) && pe politica noua sa nu faca nimic
			Thisform.do_adauga()
		Endif
		
	ENDPROC

	PROCEDURE inainte_de_do_renunt
		*!*	modificare	v 2.0.24
		Local llReturn
		llReturn = .T.
		*!*	modificare	v 2.0.26
		If This.cus_odata_comenzi1.cactiune = [UPDATE]
		*!*	modificare	v 2.0.26	^
			If Thisform.lcomandamodificata Or Thisform.oRec.lcomandareincarcata
				If aMESSAGEBOX("Ati facut modificari articolelor din comanda, dar nu le-ati salvat in baza de date." + ;
						CRLF + CRLF + "Doriti sa pastrati modificarile intr-un fisier local pentru o reincarcare ulterioara?" + ;
						CRLF + "ATENTIE : Apasati DA in cazul in care a aparut vreo eroare la salvarea in baza de date!",4+32,"Atentie") = 6
					Thisform.oRec.oBackupXML.SaveBackupSet("crscomanda_curenta")
					Thisform.oRec.oBackupXML.SaveBackupSet("DATAORA_UM","VARIABLE",Thisform.oRec.dataora_um)
				Else
					Thisform.oRec.oBackupXML.DeleteBackupSet()
				Endif
			Else
				Thisform.oRec.oBackupXML.DeleteBackupSet()
			Endif
		*!*	modificare	v 2.0.26
		Endif
		*!*	modificare	v 2.0.26	^
		Return llReturn
		*!*	modificare	v 2.0.24	^
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local llReturn
		llReturn = .T.
		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.nr_comanda)
				aMessagebox('Nu ati completat numarul comenzii!',0+48,"Atentie")
				Thisform.clb_nr_comanda.text_SIMPLU1.SetFocus()
				llReturn = .F.
			Case Empty(porec.data_comanda) Or Isnull(porec.data_comanda)
				aMessagebox('Nu ati completat data comenzii!',0+48,"Atentie")
				Thisform.clb_data_comanda.text_SIMPLU1.SetFocus()
				llReturn = .F.
			Case Inlist(Thisform.opt_interna.ListIndex,2,5) And Empty(Nvl(porec.id_part,0))				&&	modificare	v 2.0.20
				aMessagebox('Nu ati ales clientul!',0+48,"Atentie")
				Thisform.ct_nume.SetFocus()
				llReturn = .F.
			Case Thisform.opt_interna.ListIndex ==3 And (Empty(porec.id_gestiune) Or Isnull(porec.id_gestiune))
				aMessagebox('Nu ati ales gestiunea!',0+48,"Atentie")
				Thisform.ct_nume.SetFocus()
				llReturn = .F.
			Case Inlist(Thisform.opt_interna.ListIndex,2,5) And Empty(Nvl(porec.data_livrare,{}))		&&	modificare	v 2.0.20
				aMessagebox('Nu ati completat data livrarii!',0+48,"Atentie")
				Thisform.clb_data_livrare.text_SIMPLU1.SetFocus()
				llReturn = .F.
			Case Inlist(Thisform.opt_interna.ListIndex,2,5) And porec.data_livrare<porec.data_comanda	&&	modificare	v 2.0.20
				aMessagebox("Data livrarii nu poate fi mai mica decat data comenzii!",0+48,"Atentie")
				Thisform.clb_data_livrare.text_SIMPLU1.SetFocus()
				llReturn = .F.
		*!*	modificare	v 2.0.20
			Case Thisform.opt_interna.ListIndex = 5 And Empty(Nvl(porec.id_ctr,0))
				aMessagebox("Nu ati ales contractul!",48,"Atentie")
				Thisform.ct_contract.SetFocus()
				llReturn = .F.
		*!*	modificare	v 2.0.20	^
			Otherwise
		*!*	modificare	v 2.0.16
				If This.lmodificare
		*!*	modificare	v 2.0.16	^
		*!*	modificare	v 2.0.4
		*!*		llReturn = This.cus_odata_comenzi1.salvare(poRec,This.NID)
		*!*	modificare	v 2.0.25
					This.cus_odata_comenzi1.lsilent = .T.
					This.cus_odata_comenzi1.confirma_salvare()
					If This.cus_odata_comenzi1.lsalvareconfirmata
						llReturn = Thisform.do_deschide_tranzactie()
						If llReturn
							llReturn = Thisform.do_scrie_articole()
							If llReturn
								llReturn = Thisform.cus_odata_comenzi1.salvare(porec,This.NID)
							Endif
							Thisform.do_inchide_tranzactie(Iif(llReturn,1,2))
						Endif
					Endif
		*!*				llReturn = Thisform.do_deschide_tranzactie()
		*!*				If llReturn
		*!*	*!*	modificare	v 2.0.24
		*!*	*!*					llReturn = Thisform.do_scrie_articole()
		*!*	*!*					If llReturn
		*!*	*!*						llReturn = This.cus_odata_comenzi1.salvare(porec,This.NID)
		*!*	*!*					Endif
		*!*					llReturn = This.cus_odata_comenzi1.salvare(porec,This.NID)
		*!*					llReturn2 = IIF(gnButon = 1 and llReturn,.T.,.F.)
		*!*					If llReturn2
		*!*						llReturn = Thisform.do_scrie_articole()
		*!*					Endif
		*!*	*!*	modificare	v 2.0.24	^
		*!*					Thisform.do_inchide_tranzactie(Iif(llReturn and llReturn2,1,2))
		*!*				Endif
		*!*	modificare	v 2.0.25	^
		*!*	modificare	v 2.0.4	^
		*!*	modificare	v 2.0.16
				Endif
		*!*	modificare	v 2.0.16	^
		Endcase
		
		Return llReturn
		
	ENDPROC

	PROCEDURE Init
		*!* 27.09.2018
		*!* marius.mutu
		*!* sa se poata modifica clientul la modificare. nu stiu de ce nu se putea modifica si clientul
		
		*!* 26.03.2021
		*!* marius.mutu
		*!* se poate modifica si pretul. Vending master are lista de preturi cu valoare 0 si doreste sa completeze pretul manual in comanda sau la factura
		
		Lparameters toRec, tnId, tcActiune
		DoDefault()
		This.orec= toRec
		This.nid = tnId
		This.cus_odata_comenzi1.cactiune = tcActiune
		*!*	modificare	v 2.0.4
		*!*	SQLSetprop(gnHandle,"Transactions",2)	&& tranzactie manuala
		If Used('crssterse')
			Use In crssterse
		Endif
		Create Cursor crssterse(id_c N(10))
		*!*	modificare	v 2.0.4	^
		
		*!*  Combo in loc de optionbox
		Thisform.opt_interna.AddItem("Internă")
		Thisform.opt_interna.AddItem("Client")
		Thisform.opt_interna.AddItem("Gestiune")
		Thisform.opt_interna.AddItem("Sectie")
		Thisform.opt_interna.AddItem("Client - pe bază de contract")
		*!*
		
		If Empty(tnId) Or Isnull(tnId)
			Thisform.lb_articole.Visible = .F.
			Thisform.ct_articole.Visible = .F.
			Thisform.txtArticole.Visible = .F.
			Thisform.grd_articole_politica.Visible = .F.
		
			Thisform.lb_comanda.Visible=.F.
			Thisform.txtArticoleLista.Visible=.F.
			Thisform.grd_comanda_curenta.Visible=.F.
			Thisform.but_precedent1.Visible=.F.
			Thisform.but_urmator1.Visible=.F.
			Thisform.clb_tx_total.Visible = .F.
			Private pdDataComanda
			pdDataComanda = {}
			actualizeazaSetare([ORE_LIVRARE],@pdDataComanda)
			poRec.data_comanda = pdDataComanda
			poRec.data_livrare = poRec.data_comanda + Nvl(gnOre_Livrare,0) * 3600
		
			thisform.Width = 800 && INT(_screen.Width * 0.7)
			Thisform.Height = 180
			Thisform.AutoCenter = .T.
		Else
			thisform.Width = INT(_screen.Width * 0.7)
			Thisform.Height = INT(_screen.Height * 0.7)
			Thisform.AutoCenter = .T.
		
			Thisform.do_calculeaza_total()
		*!* sa se poata modifica clientul la modificare. nu stiu de ce nu se putea modifica si clientul
		*!*	Thisform.ct_nume.do_dezactiveaza()
		
		
			Thisform.gridextra1.setup()
			thisform.gridextra2.setup()
		Endif
		
		lcCriteriuDenumire = goExport.citesteSetareRegistru("CRITDENUMIRE")
		If !Empty(lcCriteriuDenumire) And Type('VAL(lcCriteriuDenumire)') = 'N'
			Thisform.ncritDenumire = Val(lcCriteriuDenumire)
		Endif
		Thisform.ct_articole.Value = Thisform.ncritDenumire
		Thisform.txtArticole.Value = []
		
		
		If tcActiune = 'INSERT'
			Thisform.opt_interna.ListIndex = gnTipUzualComanda
		Else
			Thisform.opt_interna.ListIndex = toRec.interna
		Endif
		
		*!*	modificare	v 2.0.10
		*!*	Thisform.arata_date(toRec.interna)
		Thisform.arata_date()
		*!*	modificare	v 2.0.10	^
		If tcActiune = 'UPDATE'
			Thisform.opt_interna.Enabled = .F.
			Thisform.arataadrese()
			Thisform.arata_coduri_clienti()
			Thisform.txtArticole.SetFocus()
			*!*	modificare	v 2.0.16
			This.lmodificare = Isnull(toRec.cmesajverificare)
			If !This.lmodificare
				Thisform.clb_tx_simplu1.text_simplu1.ReadOnly = .T.
				Thisform.opt_interna.ReadOnly = .T.
				Thisform.clb_data_livrare.text_simplu1.ReadOnly = .T.
				Thisform.clb_data_comanda.text_simplu1.ReadOnly = .T.
				Thisform.cmb_CodClient.ReadOnly = .T.
				Thisform.cmb_adresaFacturare.ReadOnly = .T.
				Thisform.cmb_AdresaLivrare.ReadOnly = .T.
				Thisform.clb_tx_simplu2.text_simplu1.ReadOnly = .T.
				Thisform.but_urmator1.Visible = .F.
				Thisform.but_precedent1.Visible = .F.
				amessagebox(toRec.cmesajverificare,48,"Atentie")
			Else
			*!*	modificare	v 2.0.16	^
				*!*	modificare	v 2.0.4
				With Thisform.grd_comanda_curenta
					.ReadOnly = .F.
					*!*	modificare v 2.0.8
					For i = 1 To .ColumnCount
						If !INLIST(Upper(.Columns[i].Name),'CPRET', 'CCANTITATE')
							.Columns[i].ReadOnly = .T.
						Endif
					Endfor
					*!*	modificare v 2.0.8	^
				
					.ccantitate.DynamicBackColor = "RGB(193,237,255)"
					.ccantitate.ReadOnly = .F.
					
					llSuprascriePret = Iif(Type('gnSuprascriePretComanda') = 'N', m.gnSuprascriePretComanda = 1, .F.)
					IF m.llSuprascriePret
						.cpret.DynamicBackColor = "RGB(193,237,255)"
						.cpret.ReadOnly = .F.
					ELSE 	
						.cpret.ReadOnly = .T.
					ENDIF 				
			
				Endwith
				*!*	modificare	v 2.0.4	^
			*!*	modificare	v 2.0.16
			Endif
			*!*	modificare	v 2.0.16	^
		ENDIF
		
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		lcControl = Upper(Alltrim(Thisform.ActiveControl.Name))
		
		Do Case
		Case nKeyCode = 13 And lcControl = 'GRD_ARTICOLE_POLITICA'
			Nodefault
			Thisform.but_urmator1.SetFocus()
		Case nKeyCode = 13 And lcControl = 'BUT_URMATOR1'
			Nodefault
			Thisform.do_urmator()
			Thisform.txtArticole.SetFocus()
		Case nKeyCode = 13 And lcControl = 'GRD_COMANDA_CURENTA'
			Nodefault
			Thisform.txtArticole.SetFocus()
		Case nKeyCode = 7 And lcControl = 'GRD_COMANDA_CURENTA'
			Nodefault
			Thisform.do_precedent()
		Case lcControl = 'TXTARTICOLELISTA' And nKeyCode = 13
			Nodefault
			lcArticolCautat = Alltrim(Thisform.txtArticoleLista.Value)
			If Used('crscomanda_curenta')
				Select crscomanda_curenta
				Locate For Substr(Alltrim(denumire),1,Len(lcArticolCautat)) = lcArticolCautat
				If Found()
					Thisform.grd_comanda_curenta.SetFocus()
				Else
					Thisform.txtArticoleLista.SetFocus()
				Endif
			Endif
		Case InList(lcControl,'TXTARTICOLE') And nKeyCode = 13
			Nodefault
			If Used('v_articole')
				Select v_articole
				lnRecno = Recno()
				SET STEP ON 
				lcFiltru = Thisform.do_creeaza_filtru(Thisform.ct_articole,[nume_articol],Alltrim(Strtran(Thisform.txtArticole.Value,['],[''])))
				lcFiltru = lcFiltru + [ OR ] + Thisform.do_creeaza_filtru(Thisform.ct_articole,[codmat],Alltrim(Strtran(Thisform.txtArticole.Value,['],[''])))
				lcFiltru = lcFiltru + [ OR ] + Thisform.do_creeaza_filtru(Thisform.ct_articole,[codbare],Alltrim(Strtran(Thisform.txtArticole.Value,['],[''])))
				IF thisform.chkStoc.Value = 1
					lcFiltru = lcFiltru + [ AND STOC > 0]
				ENDIF 
				Set filter to &lcFiltru
				Go top
				Thisform.grd_articole_politica.SetFocus()
		*!*		go top
		*!*		locate for &lcFiltru
		*!*			If Found()
		*!*				thisform.grd_articole_politica.SetFocus()
		*!*			Else
		*!*				amessagebox("Articolul nu a fost gasit!",48,"Atentie")
		*!*				Go lnRecno
		*!*				If lcControl = [TXTARTICOLE]
		*!*					Thisform.txtArticole.SetFocus()
		*!*				Else
		*!*					Thisform.txtcodmat.SetFocus()
		*!*				EndIf
		*!*			Endif
			Endif
		Case nKeyCode=27 And nShiftAltCtrl=0
			Nodefault
			If aMessagebox("Sunteti sigur ca doriti sa inchideti fereastra?",4+32+256,"Confirmare")==6
				This.do_renunt()
			Endif
		Case nKeyCode=6 And nShiftAltCtrl=2
			Nodefault
			This.do_termin()
		Endcase
		
	ENDPROC

	PROCEDURE showadresafacturarelivrare
		Lparameters llShow
		
		If llShow=.T.
			Thisform.lbl_Adresadefacturare.Visible= .T.
			Thisform.lbl_AdresadeLivrare.Visible=.T.
			Thisform.cmb_AdresaFacturare.Visible=.T.
			Thisform.cmb_AdresaLivrare.Visible=.T.
		Else
			Thisform.lbl_Adresadefacturare.Visible= .F.
			Thisform.lbl_AdresadeLivrare.Visible=.F.
			Thisform.cmb_AdresaFacturare.Visible=.F.
			Thisform.cmb_AdresaLivrare.Visible=.F.
		Endif
		
	ENDPROC

	PROCEDURE show_cod_client
		Lparameters llShow
		
		If llShow=.T.
			Thisform.cmb_CodClient.Visible=.T.
			Thisform.lbl_codclient.Visible= .T.
		Else
			Thisform.cmb_CodClient.Visible=.F.
			Thisform.lbl_codclient.Visible= .F.
		Endif
		
	ENDPROC

	PROCEDURE clb_data_comanda.TEXT_SIMPLU1.InteractiveChange
		If Empty(Thisform.nid)
			poRec.data_livrare = This.Value + gnOre_livrare * 3600
			Thisform.clb_data_livrare.Refresh()
		Endif
	ENDPROC

	PROCEDURE cmb_AdresaFacturare.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ToolTipText=ALLTRIM(this.list(this.ListIndex,2))
	ENDPROC

	PROCEDURE cmb_AdresaFacturare.Valid
		porec.Id_facturare=v_adrese.id_adresa
	ENDPROC

	PROCEDURE cmb_AdresaLivrare.MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord
		this.ToolTipText=ALLTRIM(this.list(this.ListIndex,2))
	ENDPROC

	PROCEDURE cmb_AdresaLivrare.Valid
		porec.Id_livrare=v_adrese.id_adresa
	ENDPROC

	PROCEDURE cmb_CodClient.Valid
		porec.id_codclient=v_coduri.id
	ENDPROC

	PROCEDURE ct_articole.InteractiveChange
		With Thisform.txtArticole
			If This.Value>5
				.Value=""
				.ReadOnly=.T.
			Else
				.ReadOnly=.F.
				.SetFocus()
			Endif
		Endwith
		
	ENDPROC

	PROCEDURE grd_articole_politica.Init
		* Nu sterge
	ENDPROC

	PROCEDURE grd_comanda_curenta.cCantitate.Text1.GotFocus
		Thisform.ncantitate_init = This.Value
	ENDPROC

	PROCEDURE grd_comanda_curenta.cCantitate.Text1.LostFocus
		If Thisform.ncantitate_init <> This.Value
			Thisform.do_modifica(This.Value)
		Endif
		Thisform.ncantitate_init = 0
	ENDPROC

	PROCEDURE grd_comanda_curenta.cPret.Text1.GotFocus
		Thisform.npret_init = This.Value
	ENDPROC

	PROCEDURE grd_comanda_curenta.cPret.Text1.LostFocus
		If Thisform.npret_init <> This.Value
			Thisform.do_modifica(This.Value)
		Endif
		Thisform.npret_init = 0
	ENDPROC

	PROCEDURE grd_comanda_curenta.Init
		* Nu sterge
	ENDPROC

	PROCEDURE opt_interna.InteractiveChange
		*!*	modificare	v 2.0.10
		*!*	Thisform.arata_date(This.ListIndex)
		Thisform.arata_date()
		*!*	modificare	v 2.0.10
		thisform.showadresafacturarelivrare(.F.)
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_livrare 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_data_livrat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_agent" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_delegat" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_masina" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_agent
		*m: do_cauta_delegat
		*m: do_cauta_masina
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 163
		Name = "frm_livrare"
		Width = 374
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "DETALII LIVRARE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Left = 344
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

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

	ADD OBJECT 'clb_data_livrat' AS clb_tx_simplu WITH ;
		Left = 29, ;
		Name = "clb_data_livrat", ;
		TabIndex = 4, ;
		Top = 128, ;
		Text_simplu1.ControlSource = "podetlivrare.data_livrat", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data livrat", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_agent' AS ct_clb_cautare WITH ;
		cconditie = 1=2, ;
		cprocedura = Thisform.do_cauta_agent, ;
		cvar_afisata = podetlivrare.nume_agent, ;
		Left = 28, ;
		Name = "Ct_clb_agent", ;
		TabIndex = 1, ;
		Top = 43, ;
		Width = 330, ;
		IMG_CAUTARE.Left = 300, ;
		IMG_CAUTARE.Name = "IMG_CAUTARE", ;
		IMG_CAUTARE.Top = 5, ;
		CLB_TX_CAUTARE.Height = 29, ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Caption = "Agent", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		CLB_TX_CAUTARE.Left = 1, ;
		CLB_TX_CAUTARE.Name = "CLB_TX_CAUTARE", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Left = 102, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Top = 3, ;
		CLB_TX_CAUTARE.Top = 1, ;
		CLB_TX_CAUTARE.Width = 290
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_delegat' AS ct_clb_cautare WITH ;
		cconditie = Empty(podetlivrare.id_delegat), ;
		cprocedura = Thisform.do_cauta_delegat, ;
		cvar_afisata = podetlivrare.nume_delegat, ;
		Left = 28, ;
		Name = "Ct_clb_delegat", ;
		TabIndex = 2, ;
		Top = 71, ;
		Width = 330, ;
		IMG_CAUTARE.Left = 300, ;
		IMG_CAUTARE.Name = "IMG_CAUTARE", ;
		IMG_CAUTARE.Top = 5, ;
		CLB_TX_CAUTARE.Height = 29, ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Caption = "Delegat", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		CLB_TX_CAUTARE.Left = 1, ;
		CLB_TX_CAUTARE.Name = "CLB_TX_CAUTARE", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Left = 102, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Top = 3, ;
		CLB_TX_CAUTARE.Top = 1, ;
		CLB_TX_CAUTARE.Width = 290
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_masina' AS ct_clb_cautare WITH ;
		cconditie = Empty(podetlivrare.id_masina), ;
		cprocedura = Thisform.do_cauta_masina, ;
		cvar_afisata = podetlivrare.nrinmat, ;
		Left = 28, ;
		Name = "Ct_clb_masina", ;
		TabIndex = 3, ;
		Top = 99, ;
		Width = 330, ;
		IMG_CAUTARE.Left = 300, ;
		IMG_CAUTARE.Name = "IMG_CAUTARE", ;
		IMG_CAUTARE.Top = 5, ;
		CLB_TX_CAUTARE.Height = 29, ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Caption = "Masina", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		CLB_TX_CAUTARE.Left = 1, ;
		CLB_TX_CAUTARE.Name = "CLB_TX_CAUTARE", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Left = 102, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Top = 3, ;
		CLB_TX_CAUTARE.Top = 1, ;
		CLB_TX_CAUTARE.Width = 290
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />
	
	PROCEDURE do_cauta_agent
		Private pnIdPart,pcNumePart
		lcTitlu=[ALEGETI AGENTUL]
		pnIdPart=0
		pcNumePart=[]
		
		If caut_partener_dupa_tip(gnIdTipAgenti,lcTitlu,@pnIdPart,@pcNumePart)
			podetlivrare.id_agent = pnIdPart
			podetlivrare.nume_agent = Alltrim(pcNumePart)
			Thisform.ct_clb_agent.Refresh()
			Thisform.ct_clb_delegat.SetFocus()
		Endif
	ENDPROC

	PROCEDURE do_cauta_delegat
		Local loCauta
		loCauta=caut_delegati()
		If !Empty(loCauta.id_responsabil)
			podetlivrare.id_delegat = loCauta.id_responsabil
			podetlivrare.nume_delegat = Alltrim(loCauta.nume)
			lcBi = Strtran(loCauta.bi,[ ],[])
			podetlivrare.serie_bi = Substr(lcBi,1,2)
			podetlivrare.numar_bi = Substr(lcBi,3)
			podetlivrare.eliberatde = Alltrim(loCauta.eliberatde)
			Thisform.ct_clb_delegat.SetFocus()
			Thisform.ct_clb_masina.SetFocus()
		Endif
		
	ENDPROC

	PROCEDURE do_cauta_masina
		locauta=caut_masina_gs()
		If !Isnull(locauta)
			podetlivrare.nrinmat = Alltrim(locauta.nrinmat)
			podetlivrare.id_masina = locauta.id_masina
		
			Thisform.ct_clb_masina.SetFocus()
			Thisform.clb_data_livrat.text_simplu1.SetFocus()
		Endif
		
	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(podetlivrare.id_agent)
		*!*		amessagebox('Nu ati ales agentul!',0+48,"Atentie")
		*!*		Thisform.ct_clb_agent.SetFocus()
		*!*		plReturn=.F.
		
		Case Empty(podetlivrare.id_delegat)
			amessagebox('Nu ati ales delegatul!',0+48,"Atentie")
			Thisform.ct_clb_delegat.SetFocus()
			plReturn=.F.
		
		*!*	Case Empty(podetlivrare.id_masina)
		*!*		amessagebox('Nu ati ales masina!',0+48,"Atentie")
		*!*		Thisform.ct_clb_masina.SetFocus()
		*!*		plReturn=.F.
		
		Case Empty(podetlivrare.data_livrat)
			amessagebox('Nu ati completat data livrarii!',0+48,"Atentie")
			Thisform.clb_data_livrat.text_simplu1.SetFocus()
			plReturn=.F.
		
		Case podetlivrare.data_livrat<=podetlivrare.data_comanda
			amessagebox('Data livrarii nu poate fi mai mica decat '+Ttoc(podetlivrare.data_comanda)+Chr(13)+Chr(10)+;
				'(maximul datei comenzilor dintre cele selectate) !',0+48,"Atentie")
			Thisform.clb_data_livrat.text_simplu1.SetFocus()
			plReturn=.F.
		Otherwise
			plReturn=.T.
		Endcase
		Return plReturn
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_lucrari_detalii_nou AS _frmbase OF "..\comun\clase\_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="clb_nrord" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_data_lucrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="clb_termen_executie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cus_odata_lucrari_detalii1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ed_explicatie" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 205
		Name = "frm_lucrari_detalii_nou"
		Width = 374
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "LUCRARE"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Left = 344
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 314, ;
		Name = "But_renunt1", ;
		TabIndex = 6, ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'clb_data_lucrare' AS clb_tx_simplu WITH ;
		Left = 29, ;
		Name = "clb_data_lucrare", ;
		TabIndex = 2, ;
		Top = 72, ;
		Text_simplu1.ControlSource = "porec.data_lucrare", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data lucrare", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_nrord' AS clb_tx_simplu WITH ;
		Left = 29, ;
		Name = "clb_nrord", ;
		TabIndex = 1, ;
		Top = 44, ;
		Text_simplu1.ControlSource = "porec.nrord", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Nr. lucrare", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_termen_executie' AS clb_tx_simplu WITH ;
		Left = 29, ;
		Name = "clb_termen_executie", ;
		TabIndex = 4, ;
		Top = 157, ;
		Text_simplu1.ControlSource = "porec.termen_executie", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Termen executie", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Cus_odata_lucrari_detalii1' AS cus_odata_lucrari_detalii WITH ;
		Left = 336, ;
		Name = "Cus_odata_lucrari_detalii1", ;
		Top = 36
		*< END OBJECT: ClassLib="ocomenzi.vcx" BaseClass="custom" />

	ADD OBJECT 'Ed_explicatie' AS ed_tx_simplu WITH ;
		Left = 29, ;
		Name = "Ed_explicatie", ;
		TabIndex = 3, ;
		Top = 100, ;
		_edbase1.ControlSource = "porec.explicatie", ;
		_edbase1.Name = "_edbase1", ;
		_LBBASE1.Caption = "Explicatie", ;
		_LBBASE1.Name = "_LBBASE1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />
	
	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.nrord)
			amessagebox('Nu ati completat numarul lucrarii!',0+48,"Atentie")
			Thisform.clb_nrord.texT_SIMPLU1.SetFocus()
			plReturn=.F.
		Case Empty(porec.data_lucrare)
			amessagebox('Nu ati completat data lucrarii!',0+48,"Atentie")
			Thisform.clb_data_lucrare.texT_SIMPLU1.SetFocus()
			plReturn=.F.
		Case Empty(porec.termen_executie)
			amessagebox('Nu ati completat termenul de executie!',0+48,"Atentie")
			Thisform.clb_termen_executie.texT_SIMPLU1.SetFocus()
			plReturn=.F.
		Case porec.termen_executie<=porec.data_lucrare
			amessagebox('Termenul de executie trebuie sa fie mai mare decat data lucrarii!',0+48,"Atentie")
			Thisform.clb_termen_executie.texT_SIMPLU1.SetFocus()
			plReturn=.F.
		Otherwise
			lnRaspuns = 6
			If Upper(Alltrim(This.cus_odata_lucrari_detalii1.cactiune))=='UPDATE'
				If Used('crsdata')
					Use In crsdata
				Endif
				*lcSql = [select sysdate + (pack_comenzi.citeste_ore_inchidere()/24) as data from dual]
				lcSql = [select sysdate + (pack_comenzi.citeste_ore_inchidere(?gnId_sectie)/24) as data from dual]
				lcCursor=[crsdata]
				lnSucces=goExecutor.oExecute(lcSql,lcCursor)
				If lnSucces<0
					amessagebox(goExecutor.cEroare,0+48,"Eroare")
					Return .F.
				Endif
				Select crsdata
				ldDatainchidere = Data
				If ldDatainchidere >= porec.termen_executie
					lnRaspuns=amessagebox("Termenul de executie al acestei lucrari este mai mic decat data"+;
						CHR(13)+CHR(10)+"de la care ea este considerata inchisa ( "+TTOC(ldDatainchidere)+" ) "+;
						CHR(13)+CHR(10)+"si nu veti mai putea face modificari sau adauga comenzi pe ea."+;
						CHR(13)+CHR(10)+CHR(13)+CHR(10)+SPACE(25)+"Doriti sa continuati?"+CHR(13)+CHR(10),4+32+256,"Confirmare modificare")
				Endif
				Use In crsdata
			Endif
			If lnRaspuns = 6
				plReturn = Thisform.cus_odata_lucrari_detalii1.salvare(This.OREC,This.NID)
			Else
				plReturn = .F.
			Endif
			Thisform.clb_termen_executie.SetFocus()
		Endcase
		Return plReturn
		
	ENDPROC

	PROCEDURE Init
		Lparameters toRec, tnId, tcActiune
		
		DoDefault()
		
		This.orec= toRec
		This.nid = tnId
		This.cus_odata_lucrari_detalii1.cactiune = tcActiune
		If tcActiune = 'INSERT'
			Private pdDataLucrare
			pdDataLucrare = {}
			actualizeazaSetare([ORE_EXECUTIE],@pdDataLucrare)
			poRec.data_lucrare = pdDataLucrare
		Endif
	ENDPROC

	PROCEDURE KeyPress
		Lparameters nKeyCode, nShiftAltCtrl
		If nKeyCode = 9 And This.ActiveControl.Class =  "Ed_tx_simplu"
			Nodefault
			Thisform.clb_termen_executie.SetFocus()
		Else
			DoDefault(nKeyCode,nShiftAltCtrl)
		Endif
	ENDPROC

	PROCEDURE clb_data_lucrare.Text_simplu1.LostFocus
		If Upper(Alltrim(Thisform.cus_odata_lucrari_detalii1.cactiune))=='INSERT'
			porec.termen_executie = porec.data_lucrare + gnOre_executie*3600
			Thisform.clb_termen_executie.text_simplu1.Refresh
		Endif
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_optiuni_comenzi 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="opt_grupaart_sectie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_explicatie3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="tx_ore_inchidere" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="tx_ore_executie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="tx_ore_livrare" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_politica_preturi_subunitati" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie5" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ct_gestiuni_stoc" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_gestiuni_stoc" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="ct_gestiuni_depozit" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_simplu9" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_politica_preturi_prod" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_simplu10" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie6" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_politica_preturi_clienti" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="op_copiere_comenzi" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_explicatie7" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Lb_simplu8" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_grupaart_sectie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="tx_minsescomanda" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="op_pret" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="_linie1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_tip_uzual_comanda" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="opt_comenzi_initial" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="op_ordonare" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_alege_gest_dep
		*m: do_alege_gest_stoc
		*m: do_alege_grupa
		*m: do_alege_politica
		*p: cgrupaartsectie
		*p: cid_gestdep_sectie
		*p: cid_geststoc_sectie		&& lista id-uri gestiuni stoc pe sectie
		*p: cnumegestdep		&& Gestiuni depozit pe sectie pentru raport comenzi bazat pe vanzari
		*p: cnumegeststoc		&& Lista gestiuni din care se afiseaza stocul pentru editare comenzi
		*p: cnumepolitica
		*p: cnumepoliticaclienti
		*p: cnumepoliticaprod
		*p: nid
		*p: nid_grupaart_sectie
		*p: nid_pol
		*p: nid_pol_clienti
		*p: nid_pol_prod
		*p: nminsescomanda
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		Caption = "Form"
		cgrupaartsectie = 
		cid_gestdep_sectie = 
		cid_geststoc_sectie = 
		cnumegestdep = 
		cnumegeststoc = 
		cnumepolitica = 
		cnumepoliticaclienti = 
		cnumepoliticaprod = 
		DoCreate = .T.
		Height = 550
		Name = "frm_optiuni_comenzi"
		nid_grupaart_sectie = 0
		nid_pol = 
		nid_pol_clienti = 
		nid_pol_prod = 
		nminsescomanda = .NULL.
		Width = 733
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 744
		_shape1.ZOrderSet = 2
		_shape2.Height = 29
		_shape2.Left = 672
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		_shape2.ZOrderSet = 3
		Lb_titlu_alb_b121.Caption = "OPȚIUNI COMENZI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 19
		Lb_titlu_alb_b121.ZOrderSet = 4
		BUT_TERMIN1.Left = 702
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 17
		BUT_TERMIN1.Top = 1
		BUT_TERMIN1.ZOrderSet = 5
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT '_linie1' AS _linie WITH ;
		Height = 504, ;
		Left = 365, ;
		Name = "_linie1", ;
		Top = 36, ;
		Width = 0, ;
		ZOrderSet = 31
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="line" />

	ADD OBJECT '_shape3' AS _shape WITH ;
		BackStyle = 0, ;
		Height = 51, ;
		Left = 373, ;
		Name = "_shape3", ;
		Top = 265, ;
		Width = 314, ;
		ZOrderSet = 0
		*< END OBJECT: ClassLib="..\..\..\roagest\comun\clase\_baza.vcx" BaseClass="shape" />

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

	ADD OBJECT 'ct_gestiuni_depozit' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cnumegestdep,'')) AND EMPTY(NVL(gcLISTA_GEST_DEP,'')), ;
		clista_parametri = , ;
		cprocedura = Thisform.do_alege_gest_dep, ;
		cvar_afisata = thisform.cnumegestdep, ;
		Left = 370, ;
		Name = "ct_gestiuni_depozit", ;
		TabIndex = 9, ;
		Top = 124, ;
		ZOrderSet = 18, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Gestiuni", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 61, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 249
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'ct_gestiuni_stoc' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cnumegestdep,'')) AND EMPTY(NVL(gcLISTA_GEST_DEP,'')), ;
		clista_parametri = , ;
		cprocedura = Thisform.do_alege_gest_stoc, ;
		cvar_afisata = thisform.cnumegeststoc, ;
		Left = 372, ;
		Name = "ct_gestiuni_stoc", ;
		TabIndex = 10, ;
		Top = 186, ;
		ZOrderSet = 16, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Gestiuni", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Height = 23, ;
		clb_tx_cautare.Text_simplu1.Left = 61, ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1", ;
		clb_tx_cautare.Text_simplu1.Top = 3, ;
		clb_tx_cautare.Text_simplu1.Width = 249
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_grupaart_sectie' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cgrupaartsectie,'')) AND EMPTY(NVL(Thisform.nid_grupaart_sectie,0)), ;
		cprocedura = Thisform.do_alege_grupa, ;
		cvar_afisata = thisform.cgrupaartsectie, ;
		Left = 12, ;
		Name = "Ct_grupaart_sectie", ;
		TabIndex = 15, ;
		Top = 498, ;
		ZOrderSet = 28, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Grupa de articole", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_politica_preturi_clienti' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cnumepoliticaclienti,'')) AND EMPTY(NVL(gnIdPoliticaPretC,0)), ;
		clista_parametri = 1, ;
		cprocedura = Thisform.do_alege_politica, ;
		cvar_afisata = thisform.cnumepoliticaclienti, ;
		Left = 12, ;
		Name = "Ct_politica_preturi_clienti", ;
		TabIndex = 6, ;
		Top = 189, ;
		Visible = .T., ;
		ZOrderSet = 23, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Politica de preturi", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_politica_preturi_prod' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cnumepoliticaprod,'')) AND EMPTY(NVL(gnID_LISTA_PRETURI_PV,0)), ;
		clista_parametri = 3, ;
		cprocedura = Thisform.do_alege_politica, ;
		cvar_afisata = thisform.cnumepoliticaprod, ;
		Left = 12, ;
		Name = "Ct_politica_preturi_prod", ;
		TabIndex = 8, ;
		Top = 312, ;
		ZOrderSet = 20, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Politica de preturi", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_politica_preturi_subunitati' AS ct_clb_cautare WITH ;
		cconditie = EMPTY(NVL(thisform.cnumepolitica,'')) AND EMPTY(NVL(gnIdPoliticaPret,0)), ;
		clista_parametri = 2, ;
		cprocedura = Thisform.do_alege_politica, ;
		cvar_afisata = thisform.cnumepolitica, ;
		Left = 12, ;
		Name = "Ct_politica_preturi_subunitati", ;
		TabIndex = 7, ;
		Top = 257, ;
		ZOrderSet = 14, ;
		img_cautare.Name = "img_cautare", ;
		clb_tx_cautare.Lb_simplu1.Caption = "Politica de preturi", ;
		clb_tx_cautare.Lb_simplu1.Name = "Lb_simplu1", ;
		clb_tx_cautare.Name = "clb_tx_cautare", ;
		clb_tx_cautare.Text_simplu1.Name = "Text_simplu1"
		*< END OBJECT: ClassLib="caut_ora.vcx" BaseClass="container" />

	ADD OBJECT 'Lb_explicatie1' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Termenul de executie propus la adaugarea unei lucrari este de                        ore de la data lucrarii.", ;
		Height = 34, ;
		Left = 12, ;
		Name = "Lb_explicatie1", ;
		TabIndex = 28, ;
		Top = 41, ;
		Width = 313, ;
		WordWrap = .T., ;
		ZOrderSet = 10
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_explicatie2' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Termenul de livrare uzual pentru o comanda este de                          ore.", ;
		Height = 34, ;
		Left = 12, ;
		Name = "Lb_explicatie2", ;
		TabIndex = 30, ;
		Top = 76, ;
		Width = 324, ;
		WordWrap = .T., ;
		ZOrderSet = 12
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'lb_explicatie3' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "O lucrare este considerata închisa cu                        ore înainte de termenul de executie.", ;
		Height = 34, ;
		Left = 12, ;
		Name = "lb_explicatie3", ;
		TabIndex = 27, ;
		Top = 114, ;
		Width = 294, ;
		WordWrap = .T., ;
		ZOrderSet = 8
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_explicatie4' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Alegeti politica de preturi implicita pentru comenzile de la clienti:", ;
		Height = 31, ;
		Left = 12, ;
		Name = "Lb_explicatie4", ;
		TabIndex = 23, ;
		Top = 158, ;
		Visible = .T., ;
		Width = 348, ;
		WordWrap = .T., ;
		ZOrderSet = 24
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_explicatie5' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Alegeti politica de preturi implicita pentru comenzile de la subunitati:", ;
		Height = 34, ;
		Left = 12, ;
		Name = "Lb_explicatie5", ;
		TabIndex = 20, ;
		Top = 223, ;
		Width = 324, ;
		WordWrap = .T., ;
		ZOrderSet = 15
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_explicatie6' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Alegeti politica de preturi implicita pentru productie:", ;
		Height = 18, ;
		Left = 12, ;
		Name = "Lb_explicatie6", ;
		TabIndex = 25, ;
		Top = 291, ;
		Width = 296, ;
		WordWrap = .T., ;
		ZOrderSet = 22
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_explicatie7' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Tip uzual comanda", ;
		Height = 18, ;
		Left = 15, ;
		Name = "Lb_explicatie7", ;
		TabIndex = 21, ;
		Top = 397, ;
		Width = 109, ;
		WordWrap = .T., ;
		ZOrderSet = 26
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'lb_gestiuni_stoc' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Alegeti gestiunile pentru afisare stoc in editare comenzi", ;
		Height = 18, ;
		Left = 375, ;
		Name = "lb_gestiuni_stoc", ;
		TabIndex = 26, ;
		Top = 167, ;
		Width = 320, ;
		WordWrap = .T., ;
		ZOrderSet = 17
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_simplu10' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Se afiseaza initial comenzile", ;
		Height = 18, ;
		Left = 380, ;
		Name = "Lb_simplu10", ;
		TabIndex = 22, ;
		Top = 271, ;
		Width = 165, ;
		WordWrap = .T., ;
		ZOrderSet = 21
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_simplu8' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Numarul de minute în care nu se pot face alte operatii pe o comanda blocata este de                      minute.", ;
		Height = 34, ;
		Left = 372, ;
		Name = "Lb_simplu8", ;
		TabIndex = 29, ;
		Top = 41, ;
		Width = 340, ;
		WordWrap = .T., ;
		ZOrderSet = 27
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'Lb_simplu9' AS lb_simplu WITH ;
		AutoSize = .F., ;
		Caption = "Alegeti gestiunile tip depozit pentru comenzi bazate pe vanzari", ;
		Height = 34, ;
		Left = 373, ;
		Name = "Lb_simplu9", ;
		TabIndex = 24, ;
		Top = 90, ;
		Width = 319, ;
		WordWrap = .T., ;
		ZOrderSet = 19
		*< END OBJECT: ClassLib="lb.vcx" BaseClass="label" />

	ADD OBJECT 'op_copiere_comenzi' AS op_tx_simplu WITH ;
		Height = 51, ;
		Left = 12, ;
		Name = "op_copiere_comenzi", ;
		TabIndex = 13, ;
		Top = 341, ;
		Width = 315, ;
		ZOrderSet = 25, ;
		Lb_simplu1.AutoSize = .F., ;
		Lb_simplu1.Caption = "La copierea unei comenzi,în cazul în care sunt diferente, se scriu cantitatile diminuate?", ;
		Lb_simplu1.Height = 32, ;
		Lb_simplu1.Left = 8, ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.Top = 10, ;
		Lb_simplu1.Width = 248, ;
		Lb_simplu1.WordWrap = .T., ;
		_optiongrup1.BorderStyle = 0, ;
		_optiongrup1.Height = 46, ;
		_optiongrup1.Left = 258, ;
		_optiongrup1.Name = "_optiongrup1", ;
		_optiongrup1.OPTION1.Caption = "Da", ;
		_optiongrup1.OPTION1.Left = 5, ;
		_optiongrup1.OPTION1.Name = "OPTION1", ;
		_optiongrup1.OPTION1.Top = 5, ;
		_optiongrup1.OPTION1.Value = 0, ;
		_optiongrup1.OPTION2.Caption = "Nu", ;
		_optiongrup1.OPTION2.Left = 5, ;
		_optiongrup1.OPTION2.Name = "OPTION2", ;
		_optiongrup1.OPTION2.Top = 24, ;
		_optiongrup1.OPTION2.Value = 1, ;
		_optiongrup1.Top = 3, ;
		_optiongrup1.Value = 2, ;
		_optiongrup1.Width = 71
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'op_ordonare' AS op_tx_simplu WITH ;
		Height = 51, ;
		Left = 373, ;
		Name = "op_ordonare", ;
		TabIndex = 11, ;
		Top = 315, ;
		Width = 314, ;
		ZOrderSet = 34, ;
		Lb_simplu1.AutoSize = .T., ;
		Lb_simplu1.Caption = "Ordonare comenzi", ;
		Lb_simplu1.Height = 18, ;
		Lb_simplu1.Left = 8, ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.Top = 10, ;
		Lb_simplu1.Width = 106, ;
		Lb_simplu1.WordWrap = .T., ;
		_optiongrup1.AutoSize = .F., ;
		_optiongrup1.BorderStyle = 0, ;
		_optiongrup1.Height = 46, ;
		_optiongrup1.Left = 146, ;
		_optiongrup1.Name = "_optiongrup1", ;
		_optiongrup1.OPTION1.AutoSize = .T., ;
		_optiongrup1.OPTION1.Caption = "Cele mai vechi primele", ;
		_optiongrup1.OPTION1.Left = 5, ;
		_optiongrup1.OPTION1.Name = "OPTION1", ;
		_optiongrup1.OPTION1.Top = 5, ;
		_optiongrup1.OPTION1.Value = 1, ;
		_optiongrup1.OPTION2.AutoSize = .T., ;
		_optiongrup1.OPTION2.Caption = "Cele mai noi primele", ;
		_optiongrup1.OPTION2.Left = 5, ;
		_optiongrup1.OPTION2.Name = "OPTION2", ;
		_optiongrup1.OPTION2.Top = 24, ;
		_optiongrup1.OPTION2.Value = 0, ;
		_optiongrup1.Top = 3, ;
		_optiongrup1.Value = 1, ;
		_optiongrup1.Width = 165
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'op_pret' AS op_tx_simplu WITH ;
		Height = 51, ;
		Left = 373, ;
		Name = "op_pret", ;
		TabIndex = 12, ;
		Top = 215, ;
		Width = 314, ;
		ZOrderSet = 30, ;
		Lb_simplu1.AutoSize = .F., ;
		Lb_simplu1.Caption = "Se permite suprascrierea pretului", ;
		Lb_simplu1.Height = 32, ;
		Lb_simplu1.Left = 8, ;
		Lb_simplu1.Name = "Lb_simplu1", ;
		Lb_simplu1.Top = 10, ;
		Lb_simplu1.Width = 248, ;
		Lb_simplu1.WordWrap = .T., ;
		_optiongrup1.BorderStyle = 0, ;
		_optiongrup1.Height = 46, ;
		_optiongrup1.Left = 258, ;
		_optiongrup1.Name = "_optiongrup1", ;
		_optiongrup1.OPTION1.Caption = "Da", ;
		_optiongrup1.OPTION1.Left = 5, ;
		_optiongrup1.OPTION1.Name = "OPTION1", ;
		_optiongrup1.OPTION1.Top = 5, ;
		_optiongrup1.OPTION1.Value = 0, ;
		_optiongrup1.OPTION2.Caption = "Nu", ;
		_optiongrup1.OPTION2.Left = 5, ;
		_optiongrup1.OPTION2.Name = "OPTION2", ;
		_optiongrup1.OPTION2.Top = 24, ;
		_optiongrup1.OPTION2.Value = 1, ;
		_optiongrup1.Top = 3, ;
		_optiongrup1.Value = 2, ;
		_optiongrup1.Width = 71
		*< END OBJECT: ClassLib="lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'opt_comenzi_initial' AS combobox WITH ;
		FontCharSet = 238, ;
		Height = 24, ;
		Left = 377, ;
		Name = "opt_comenzi_initial", ;
		Style = 2, ;
		TabIndex = 3, ;
		Top = 290, ;
		Width = 302, ;
		ZOrderSet = 33
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'opt_grupaart_sectie' AS _optiongrup WITH ;
		AutoSize = .F., ;
		ButtonCount = 2, ;
		Height = 97, ;
		Left = 7, ;
		Name = "opt_grupaart_sectie", ;
		TabIndex = 14, ;
		Top = 443, ;
		Value = 1, ;
		Width = 363, ;
		ZOrderSet = 1, ;
		OPTION1.AutoSize = .T., ;
		OPTION1.Caption = "Nu se tine cont de grupa de articole la generarea automata.", ;
		OPTION1.FontCharSet = 238, ;
		OPTION1.Left = 5, ;
		OPTION1.Name = "OPTION1", ;
		OPTION1.TabIndex = 1, ;
		OPTION1.TabStop = .F., ;
		OPTION1.Top = 7, ;
		OPTION1.Value = 1, ;
		OPTION2.AutoSize = .T., ;
		OPTION2.Caption = "Acestei sectii îi corespund articolele din grupa :", ;
		OPTION2.FontCharSet = 238, ;
		OPTION2.Left = 5, ;
		OPTION2.Name = "OPTION2", ;
		OPTION2.TabIndex = 2, ;
		OPTION2.TabStop = .F., ;
		OPTION2.Top = 31, ;
		OPTION2.Value = 0
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="optiongroup" />

	ADD OBJECT 'opt_tip_uzual_comanda' AS combobox WITH ;
		FontCharSet = 238, ;
		Height = 24, ;
		Left = 14, ;
		Name = "opt_tip_uzual_comanda", ;
		Style = 2, ;
		TabIndex = 2, ;
		Top = 414, ;
		Width = 302, ;
		ZOrderSet = 32
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'tx_minsescomanda' AS _textbox WITH ;
		Format = "K!", ;
		Height = 23, ;
		InputMask = "999", ;
		Left = 531, ;
		Name = "tx_minsescomanda", ;
		TabIndex = 16, ;
		Top = 54, ;
		Width = 60, ;
		ZOrderSet = 29
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'tx_ore_executie' AS _textbox WITH ;
		Format = "K!", ;
		Height = 23, ;
		InputMask = "999", ;
		Left = 76, ;
		Name = "tx_ore_executie", ;
		TabIndex = 1, ;
		Top = 54, ;
		Width = 60, ;
		ZOrderSet = 11
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'tx_ore_inchidere' AS _textbox WITH ;
		Format = "K!", ;
		Height = 23, ;
		InputMask = "999", ;
		Left = 247, ;
		Name = "tx_ore_inchidere", ;
		TabIndex = 5, ;
		Top = 110, ;
		Width = 60, ;
		ZOrderSet = 9
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />

	ADD OBJECT 'tx_ore_livrare' AS _textbox WITH ;
		Format = "K!", ;
		Height = 23, ;
		InputMask = "999", ;
		Left = 11, ;
		Name = "tx_ore_livrare", ;
		TabIndex = 4, ;
		Top = 90, ;
		Width = 60, ;
		ZOrderSet = 13
		*< END OBJECT: ClassLib="_baza.vcx" BaseClass="textbox" />
	
	PROCEDURE do_alege_gest_dep
		Local loCauta, lcListaIdGestiuni, lcListaNumeGestiuni, lcXMLGestiune
		Local lcListaDenumire, lcListaId, llLoud, llToateIreg, lnPornire, lnTip
		lnTip = 2 && gestiunile pe care are drept utilizatorul
		llToateIreg = .F.
		lnPornire = 1 && incepe cu...,1,este...,2,nu este...,3,contine...,4,nu contine...,5,toate,6
		llLoud = .T. && daca apare messagebox "Nu ati selectat nici o inregistare" pentru cautarea multipla. Default = .F.
		lcListaId = ''
		lcListaDenumire = ''
		lcXMLGestiune = caut_gestiune_xml(lnTip, llToateIreg, lnPornire, llLoud, @lcListaId, @lcListaDenumire)
		SET STEP ON 
		If !Empty(lcXMLGestiune) And gnButon = 1
			Xmltocursor(lcXMLGestiune, "crsGestTemp")
			lcListaIdGestiuni = cursor2lista("crsGestTemp", "id_gestiune", ",")
			lcListaNumeGestiuni = cursor2lista("crsGestTemp", "cgest", ",")
			Thisform.cid_gestdep_sectie = lcListaIdGestiuni
			Thisform.cnumegestdep = lcListaNumeGestiuni
			Thisform.ct_gestiuni_depozit.SetFocus()
		
			Use In (SELECT('crsGestTemp'))
		ENDIF
		
		
		
	ENDPROC

	PROCEDURE do_alege_gest_stoc
		Local loCauta, lcListaIdGestiuni, lcListaNumeGestiuni, lcXMLGestiune
		Local lcListaDenumire, lcListaId, llLoud, llToateIreg, lnPornire, lnTip
		lnTip = 2 && gestiunile pe care are drept utilizatorul
		llToateIreg = .F.
		lnPornire = 1 && incepe cu...,1,este...,2,nu este...,3,contine...,4,nu contine...,5,toate,6
		llLoud = .T. && daca apare messagebox "Nu ati selectat nici o inregistare" pentru cautarea multipla. Default = .F.
		lcListaId = ''
		lcListaDenumire = ''
		lcXMLGestiune = caut_gestiune_xml(lnTip, llToateIreg, lnPornire, llLoud, @lcListaId, @lcListaDenumire)
		
		If !Empty(lcXMLGestiune) And gnButon = 1
			Xmltocursor(lcXMLGestiune, "crsGestTemp")
			lcListaIdGestiuni = cursor2lista("crsGestTemp", "id_gestiune", ",")
			lcListaNumeGestiuni = cursor2lista("crsGestTemp", "cgest", ",")
			Thisform.cid_geststoc_sectie = lcListaIdGestiuni
			Thisform.cnumegeststoc = lcListaNumeGestiuni
			Thisform.ct_gestiuni_stoc.SetFocus()
		
			Use In (SELECT('crsGestTemp'))
		ENDIF
		
		
	ENDPROC

	PROCEDURE do_alege_grupa
		Local loCauta
		loCauta = caut_grupa_articole()
		If !Empty(loCauta.grupa)
			Thisform.nid_grupaart_sectie = loCauta.id_grupa
			Thisform.cgrupaartsectie = loCauta.grupa
			Thisform.ct_grupaart_sectie.SetFocus()
		ENDIF
		
		
	ENDPROC

	PROCEDURE do_alege_politica
		Lparameters tnTip
		
		Local loCauta
		loCauta = caut_politici_curente_util()
		If !Empty(loCauta.nume)
			Do Case
			Case tnTip = 1
				Thisform.nid_pol_clienti = loCauta.id_pol
				Thisform.cnumepoliticaclienti = loCauta.nume
				Thisform.ct_politica_preturi_subunitati.SetFocus()
			Case tnTip = 2
				Thisform.nid_pol = loCauta.id_pol
				Thisform.cnumepolitica = loCauta.nume
				Thisform.ct_politica_preturi_prod.SetFocus()
			Case tnTip = 3
				Thisform.nid_pol_prod = loCauta.id_pol
				Thisform.cnumepoliticaprod = loCauta.nume
				Thisform.but_TERMIN1.SetFocus()
			Endcase
		Endif
		
	ENDPROC

	PROCEDURE inainte_de_do_termin
		Local lcSql, lcOptiuni, lcValori, lcSeparator, plReturn
		Local lcListaNumeGestiuni, lnCopiereCantitate, lnIdGrupaArtSectie, lnMinSesComanda, lnOre_executie
		Local lnOre_inchidere, lnOre_livrare, lnSucces, lnTipUzualComanda, lnToateGrupele, lnSuprascriePretComanda
		Local lcId_gestdep_sectie, lcId_geststoc_sectie, lcListaNumeGestiuniStoc, lnComenziInitial
		Local lnOrdonareComenzi
		*:Global gnRF_ORDONARECOMENZI
		
		*:Global gnComenziInitial, gnSuprascriePretComanda
		
		*:Global gnCopiereCantitate, gnID_LISTA_PRETURI_PV, gnIdGrupaArtSectie, gnIdPoliticaPret
		*:Global gnIdPoliticaPretC, gnOre_executie, gnOre_inchidere, gnOre_livrare, gnTipUzualComanda
		*:Global gnToateGrupele
		lcSeparator = [|]
		lcOptiuni = []
		lcValori = []
		lnOre_executie = Thisform.tx_ore_executie.Value
		lnOre_inchidere = Thisform.tx_ore_inchidere.Value
		lnOre_livrare = Thisform.tx_ore_livrare.Value
		lnCopiereCantitate = thisform.op_copiere_comenzi._optiongrup1.Value
		lnTipUzualComanda = thisform.opt_tip_uzual_comanda.ListIndex 	&&	modificare	v 2.0.20
		lnComenziInitial = thisform.opt_comenzi_initial.ListIndex
		lcListaNumeGestiuni = thisform.ct_gestiuni_depozit.clb_tx_cautare.text_simplu1.Value
		lcId_gestdep_sectie = extrage_optiuni(m.gcLISTA_GESTIUNI_DEPOZIT, m.gnId_sectie)
		
		lcListaNumeGestiuniStoc = thisform.ct_gestiuni_stoc.clb_tx_cautare.text_simplu1.Value
		lcId_geststoc_sectie = extrage_optiuni(m.gcLISTA_GESTIUNI_STOC, m.gnId_sectie)
		
		
		lnSuprascriePretComanda = Thisform.op_pret._optiongrup1.Value
		
		*!*	modificare	v 2.0.15
		lnToateGrupele = Mod(Thisform.opt_grupaart_sectie.Value, 2)
		If lnToateGrupele = 1
			lnIdGrupaArtSectie = 0
		Else
			lnIdGrupaArtSectie = Thisform.nid_grupaart_sectie
		Endif
		*!*	modificare	v 2.0.15	^
		*!*	modificare	v 2.0.16
		lnMinSesComanda = Thisform.tx_minsescomanda.Value
		*!*	modificare	v 2.0.16	^
		
		lnOrdonareComenzi = thisform.op_ordonare._opTIONGRUP1.Value 
		
		Do Case
		Case lnOre_executie < 0
			amessagebox('Numarul de ore nu poate fi negativ!', 0 + 48, "Atentie")
			Thisform.tx_ore_executie.SetFocus()
			plReturn = .F.
		Case lnOre_livrare < 0
			amessagebox('Numarul de ore nu poate fi negativ!', 0 + 48, "Atentie")
			Thisform.tx_ore_livrare.SetFocus()
			plReturn = .F.
		Case lnOre_inchidere < 0
			amessagebox('Numarul de ore nu poate fi negativ!', 0 + 48, "Atentie")
			Thisform.tx_ore_inchidere.SetFocus()
			plReturn = .F.
		Case lnOre_inchidere >= lnOre_executie
			amessagebox(Space(12) + 'Perioada propusa pentru executia unei lucrari trebuie sa fie' + Chr(13) + Chr(10) + ;
				  'mai mare decat perioada de dinaintea termenului de executie pentru care aceasta' + Chr(13) + Chr(10) + ;
				  'este considerata inchisa!', 0 + 48, 'Atentie')
			Thisform.tx_ore_executie.SetFocus()
			plReturn = .F.
		*!*	modificare	v 2.0.15
		CASE lnToateGrupele = 0 AND EMPTY(lnIdGrupaArtSectie)
			amessagebox("Nu ati ales grupa de articole pentru aceasta sectie!", 0 + 48, "Atentie")
			Thisform.ct_grupaart_sectie.SetFocus()
			plReturn = .F.
		*!*	modificare	v 2.0.15	^
		OTHERWISE
			If lnOre_inchidere <> gnOre_inchidere
				*lcValori = lcValori + Alltrim(Str(lnOre_inchidere)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcOre_inchidere, gnId_sectie, Alltrim(Str(lnOre_inchidere))) + lcSeparator
				lcOptiuni = lcOptiuni + [ORE_INCHIDERE] + lcSeparator
		*!*			lcSql=[UPDATE ]+gcS+[.OPTIUNI SET VARVALUE=']+Alltrim(Str(lnOre_inchidere))+[' WHERE UPPER(VARNAME)='ORE_INCHIDERE';]
			Endif
			If lnOre_executie <> gnOre_executie
				*lcValori = lcValori + Alltrim(Str(lnOre_executie)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcOre_executie, gnId_sectie, Alltrim(Str(lnOre_executie))) + lcSeparator
		
				lcOptiuni = lcOptiuni + [ORE_EXECUTIE] + lcSeparator
		*!*			lcSql=[UPDATE ]+gcS+[.OPTIUNI SET VARVALUE=']+Alltrim(Str(lnOre_executie))+[' WHERE UPPER(VARNAME)='ORE_EXECUTIE';]
			Endif
			If lnOre_livrare <> gnOre_livrare
				*lcValori = lcValori + Alltrim(Str(lnOre_executie)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcOre_livrare, gnId_sectie, Alltrim(Str(lnOre_livrare))) + lcSeparator
				lcOptiuni = lcOptiuni + [ORE_LIVRARE] + lcSeparator
		*!*			lcSql=[UPDATE ]+gcS+[.OPTIUNI SET VARVALUE=']+Alltrim(Str(lnOre_executie))+[' WHERE UPPER(VARNAME)='ORE_LIVRARE';]
			Endif
			If Nvl(Thisform.nid_pol_clienti, 0) <> Nvl(gnIdPoliticaPretC, 0)
				*lcValori = lcValori + Alltrim(Str(Thisform.nid_pol_clienti)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcIdPoliticaPretC, gnId_sectie, Alltrim(Str(Thisform.nid_pol_clienti))) + lcSeparator
				lcOptiuni = lcOptiuni + [IDPOLITICAPRETC] + lcSeparator
			Endif
			If Nvl(Thisform.nid_pol, 0) <> Nvl(gnIdPoliticaPret, 0)
				*lcValori = lcValori + Alltrim(Str(Thisform.nid_pol)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcIdPoliticaPret, gnId_sectie, Alltrim(Str(Thisform.nid_pol))) + lcSeparator
				lcOptiuni = lcOptiuni + [IDPOLITICAPRET] + lcSeparator
		*!*			lcSql=[UPDATE ]+gcS+[.OPTIUNI SET VARVALUE=']+Alltrim(Str(Thisform.nid_pol))+[' WHERE UPPER(VARNAME)='IDPOLITICAPRET';]
			Endif
			If Nvl(Thisform.nid_pol_prod, 0) <> Nvl(gnID_LISTA_PRETURI_PV, 0)
				lcValori = lcValori + recompune_optiuni(gcID_LISTA_PRETURI_PV, gnId_sectie, Alltrim(Str(Thisform.nid_pol_prod))) + lcSeparator
				lcOptiuni = lcOptiuni + [ID_LISTA_PRETURI_PV] + lcSeparator
			Endif
			If lnCopiereCantitate <> gnCopiereCantitate
				*lcValori = lcValori + Alltrim(Str(lnCopiereCantitate)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcCopiereCantitate, gnId_sectie, Alltrim(Str(lnCopiereCantitate))) + lcSeparator
				lcOptiuni = lcOptiuni + [COPIERECANTITATE] + lcSeparator
			ENDIF
			If lnSuprascriePretComanda <> gnSuprascriePretComanda
				lcValori = lcValori + recompune_optiuni(gcSuprascriePretComanda, gnId_sectie, Alltrim(Str(lnSuprascriePretComanda))) + lcSeparator
				lcOptiuni = lcOptiuni + [SUPRASCRIEPRETCOMANDA] + lcSeparator
			ENDIF	
			If lnTipUzualComanda <> gnTipUzualComanda
				*lcValori = lcValori + Alltrim(Str(lnCopiereCantitate)) + lcSeparator
				lcValori = lcValori + recompune_optiuni(gcTipUzualComanda, gnId_sectie, Alltrim(Str(lnTipUzualComanda))) + lcSeparator
				lcOptiuni = lcOptiuni + [TIPUZUALCOMANDA] + lcSeparator
			ENDIF
		
			If lnComenziInitial <> m.gnComenziInitial
				lcValori = lcValori + recompune_optiuni(gcComenziInitial, gnId_sectie, Alltrim(Str(lnComenziInitial))) + lcSeparator
				lcOptiuni = lcOptiuni + [COMENZIINITIAL] + lcSeparator
			ENDIF
				
		*!*	modificare	2.0.15
			If lnToateGrupele <> gnToateGrupele
				lcValori = lcValori + ALLTRIM(STR(lnToateGrupele)) + lcSeparator
				lcOptiuni = lcOptiuni + [TOATEGRUPELE] + lcSeparator
			Endif
			If lnIdGrupaArtSectie <> gnIdGrupaArtSectie
				lcValori = lcValori + recompune_optiuni(gcGrupaArtSectie, gnId_sectie, Alltrim(Str(lnIdGrupaArtSectie))) + lcSeparator
				lcOptiuni = lcOptiuni + [GRUPAARTSECTIE] + lcSeparator
			Endif
		*!*	modificare	2.0.15	^
		*!*	modificare	2.0.16
			IF NVL(lnMinSesComanda, 0) <> NVL(Thisform.nminsescomanda, 0)
				lcValori = lcValori + recompune_optiuni(gcMinSesComanda, gnId_sectie, Alltrim(Str(lnMinSesComanda))) + lcSeparator
				lcOptiuni = lcOptiuni + [MINSESCOMANDA] + lcSeparator
			ENDIF
		*!*	modificare	2.0.16	^
		
			IF NVL(Thisform.cid_gestdep_sectie, '') <> NVL(m.lcId_gestdep_sectie, '')
				lcValori = lcValori + recompune_optiuni(m.gcLISTA_GESTIUNI_DEPOZIT, gnId_sectie, Alltrim(thisform.cid_gestdep_sectie)) + lcSeparator
				lcOptiuni = lcOptiuni + [LISTA_GESTIUNI_DEPOZIT] + lcSeparator
			ENDIF
			
			IF NVL(Thisform.cid_geststoc_sectie, '') <> NVL(m.lcId_geststoc_sectie, '')
				lcValori = lcValori + recompune_optiuni(m.gcLISTA_GESTIUNI_STOC, gnId_sectie, Alltrim(thisform.cid_geststoc_sectie)) + lcSeparator
				lcOptiuni = lcOptiuni + [LISTA_GESTIUNI_STOC] + lcSeparator
			ENDIF
		
			If m.lnOrdonareComenzi <> m.gnRF_OrdonareComenzi
				lcValori = lcValori + recompune_optiuni(m.gcRF_ORDONARECOMENZI, m.gnId_sectie, Alltrim(Str(m.lnOrdonareComenzi))) + lcSeparator
				lcOptiuni = lcOptiuni + [RF_ORDONARECOMENZI] + lcSeparator
			ENDIF		
				
			If !Empty(lcOptiuni) And !Empty(lcValori)
				If amessagebox("Sunteti sigur ca doriti sa salvati modificarile facute?", 4 + 32, "Confirmare") == 6
					lcSql = [begin actualizeaza_optiuni('] + gcNumeProgram + [','] + lcOptiuni + [','] + lcValori + [','] + lcSeparator + ['); end;]
					lnSucces = goExecutor.oExecute(lcSql)
					If lnSucces < 0
						amessagebox(goExecutor.cEroare, 0 + 48, "Eroare")
						plReturn = .F.
					Else
						gnOre_inchidere = lnOre_inchidere
						gnOre_executie = lnOre_executie
						gnOre_livrare = lnOre_livrare
						gnIdPoliticaPret = Thisform.nid_pol
						gnIdPoliticaPretC = Thisform.nid_pol_clienti
						gnID_LISTA_PRETURI_PV = Thisform.nid_pol_prod
						gnCopiereCantitate = lnCopiereCantitate
						gnSuprascriePretComanda = m.lnSuprascriePretComanda
						*!*	modificare v 2.0.10
						gnTipUzualComanda = lnTipUzualComanda
						gnComenziInitial = lnComenziInitial
						*!*	modificare v 2.0.10	^				
						*!*	modificare	2.0.15
						gnToateGrupele = lnToateGrupele
						gnIdGrupaArtSectie = lnIdGrupaArtSectie
						*!*	modificare	2.0.15	^
						gnRF_ORDONARECOMENZI = m.lnOrdonareComenzi
						plReturn = .T.
					Endif
				Endif
			Else
				plReturn = .T.
			Endif
		Endcase
		Return plReturn  
	ENDPROC

	PROCEDURE Init
		Local lcOptiune, lcid_gestdep_sectie
		*:Global gnIdGrupaArtSectie, gnTipUzualComanda
		DoDefault()
		SET STEP ON 
		optiuni_firma()
		Thisform.tx_ore_inchidere.Value = gnOre_inchidere
		Thisform.tx_ore_livrare.Value = gnOre_Livrare
		Thisform.tx_ore_executie.Value = gnOre_executie
		Thisform.op_copiere_comenzi._optiongrup1.Value = gnCopiereCantitate
		Thisform.op_pret._optiongrup1.Value = gnSuprascriePretComanda
		Thisform.nid_pol_clienti = gnIdPoliticaPretC
		Thisform.cnumepoliticaclienti = caut_nume_politica(gnIdPoliticaPretC)
		Thisform.nid_pol = gnIdPoliticaPret
		Thisform.cNumePolitica = caut_nume_politica(gnIdPoliticaPret)
		Thisform.nid_pol_prod = gnID_LISTA_PRETURI_PV
		Thisform.cnumepoliticaprod = caut_nume_politica(gnID_LISTA_PRETURI_PV)
		Thisform.op_ordonare._optiongrup1.Value = m.gnRF_OrdonareComenzi
		
		*!*	modificare	v 2.0.15
		If gnToateGrupele = 0
			gnIdGrupaArtSectie = Val(extrage_optiuni(gcGrupaArtSectie, gnId_sectie))
			Thisform.nid_grupaart_sectie = gnIdGrupaArtSectie
			Thisform.cgrupaartsectie = caut_nume_grupa_art(gnIdGrupaArtSectie)
			Thisform.opt_grupaart_sectie.Value = 2
		Else
			gnIdGrupaArtSectie = 0
			Thisform.opt_grupaart_sectie.Value = 1
		Endif
		*!*	modificare	v 2.0.15	^
		***---------------
		lcOptiune = extrage_optiuni(gcTipUzualComanda, gnId_sectie)
		gnTipUzualComanda = VAL(lcOptiune)
		*!*	modificare	v 2.0.20
		With Thisform.opt_tip_uzual_comanda
			.AddItem("Interna")
			.AddItem("Client")
			.AddItem("Gestiune")
			.AddItem("Sectie")
			.AddItem("Client - pe baza de contract")
			.ListIndex = gnTipUzualComanda
		Endwith
		*!*	modificare	v 2.0.20	^
		
		lcOptiune = extrage_optiuni(gcComenziInitial, gnId_sectie)
		gnComenziInitial = VAL(lcOptiune)
		* 13.04.2021
		With Thisform.opt_comenzi_initial
			.AddItem("Toate")
			.AddItem("Facturate")
			.AddItem("Nefacturate")
			.AddItem("Nefacturate sau Recente 1 zi")
			.AddItem("Nefacturate sau Recente 3 zile")
			.AddItem("Nefacturate sau Recente 7 zile")		
			.AddItem("Nefacturate sau Recente 15 zile")
			.AddItem("Nefacturate sau Recente 30 zile")
			.AddItem("Nefacturate sau Recente 60 zile")
			.AddItem("Nefacturate sau Recente 90 zile")	
			.ListIndex = gnComenziInitial
		Endwith
		* * 13.04.2021 ^
		
		
		***---------------
		*!*	modificare	v 2.0.16
		lcOptiune = extrage_optiuni(gcMinSesComanda, gnId_sectie)
		Thisform.nminsescomanda = VAL(lcOptiune)
		thisform.tx_minsescomanda.Value = Thisform.nminsescomanda
		*!*	modificare	v 2.0.16	^
		
		
		lcid_gestdep_sectie  = extrage_optiuni(m.gcLISTA_GESTIUNI_DEPOZIT, m.gnId_sectie)
		Thisform.cid_gestdep_sectie = m.lcid_gestdep_sectie
		thisform.cnumegestdep = caut_nume_gest_dep(lcid_gestdep_sectie)
		
		lcid_geststoc_sectie  = extrage_optiuni(m.gcLISTA_GESTIUNI_STOC, m.gnId_sectie)
		Thisform.cid_geststoc_sectie = m.lcid_geststoc_sectie
		thisform.cnumegeststoc = caut_nume_gest_dep(lcid_geststoc_sectie)
		
		Thisform.ct_politica_preturi_clienti.Refresh()
		Thisform.ct_politica_preturi_subunitati.Refresh()
		Thisform.ct_politica_preturi_prod.Refresh()
	ENDPROC

	PROCEDURE opt_grupaart_sectie.InteractiveChange
		If This.Value = 1
			Thisform.cgrupaartsectie = []
			Thisform.nid_grupaart_sectie = 0
			Thisform.ct_grupaart_sectie.do_dezactiveaza()
		Else
			Thisform.ct_grupaart_sectie.do_activeaza()
		Endif
		
	ENDPROC

	PROCEDURE opt_grupaart_sectie.ProgrammaticChange
		If This.Value = 1
			Thisform.cgrupaartsectie = []
			Thisform.nid_grupaart_sectie = 0
			Thisform.ct_grupaart_sectie.do_dezactiveaza()
		Else
			Thisform.ct_grupaart_sectie.do_activeaza()
		Endif
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_vanz AS _frmbase OF "..\comun\clase\_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_datas" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_renunt1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Ct_clb_grupa_gest" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_datai" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Clb_procent" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_grupa
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 180
		Name = "frm_rap_vanz"
		Width = 374
		_shape1.Name = "_shape1"
		_shape2.Height = 29
		_shape2.Left = 312
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "VANZARI PERIOADA"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 7
		BUT_TERMIN1.Left = 344
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 5
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'But_renunt1' AS but_renunt WITH ;
		Left = 314, ;
		Name = "But_renunt1", ;
		TabIndex = 6, ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Clb_datai' AS clb_tx_simplu WITH ;
		Left = 26, ;
		Name = "Clb_datai", ;
		TabIndex = 1, ;
		Top = 46, ;
		Text_simplu1.ControlSource = "ptDataI", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data initiala", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'clb_datas' AS clb_tx_simplu WITH ;
		Left = 26, ;
		Name = "clb_datas", ;
		TabIndex = 2, ;
		Top = 74, ;
		Text_simplu1.ControlSource = "ptDataS", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Data finala", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Clb_procent' AS clb_tx_simplu WITH ;
		Left = 26, ;
		Name = "Clb_procent", ;
		TabIndex = 4, ;
		Top = 130, ;
		Text_simplu1.ControlSource = "pnProcent", ;
		Text_simplu1.InputMask = "999.99", ;
		Text_simplu1.Name = "Text_simplu1", ;
		Lb_simplu1.Caption = "Procent vanzari", ;
		Lb_simplu1.Name = "Lb_simplu1"
		*< END OBJECT: ClassLib="..\comun\clase\lb_tx.vcx" BaseClass="container" />

	ADD OBJECT 'Ct_clb_grupa_gest' AS ct_clb_cautare WITH ;
		cconditie = Empty(pcGrupaGest), ;
		cprocedura = Thisform.do_cauta_grupa, ;
		cvar_afisata = pcGrupaGest, ;
		Left = 25, ;
		Name = "Ct_clb_grupa_gest", ;
		TabIndex = 3, ;
		Top = 101, ;
		Width = 330, ;
		IMG_CAUTARE.Left = 300, ;
		IMG_CAUTARE.Name = "IMG_CAUTARE", ;
		IMG_CAUTARE.Top = 5, ;
		CLB_TX_CAUTARE.Height = 29, ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Caption = "Grupa gestiuni", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Name = "LB_SIMPLU1", ;
		CLB_TX_CAUTARE.LB_SIMPLU1.Top = 6, ;
		CLB_TX_CAUTARE.Left = 1, ;
		CLB_TX_CAUTARE.Name = "CLB_TX_CAUTARE", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Left = 102, ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Name = "TEXT_SIMPLU1", ;
		CLB_TX_CAUTARE.TEXT_SIMPLU1.Top = 3, ;
		CLB_TX_CAUTARE.Top = 1, ;
		CLB_TX_CAUTARE.Width = 290
		*< END OBJECT: ClassLib="..\comun\clase\caut_ora.vcx" BaseClass="container" />
	
	PROCEDURE do_cauta_grupa
		locauta = caut_grupa_gestiune(,.F.)
		If !Isnull(locauta)
			pcGrupaGest = Alltrim(locauta.nume_grupa)
			pnIdGrupaGest = locauta.id_grupe
		Endif
	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(Nvl(ptDataI,{}))
				amessagebox("Nu ati completat data de inceput!",48,"Atentie")
				Thisform.clb_datai.SetFocus()
				plReturn = .F.
			Case Empty(Nvl(ptDataS,{}))
				amessagebox("Nu ati completat data de final!",48,"Atentie")
				Thisform.clb_datas.SetFocus()
				plReturn = .F.
			Case Empty(Nvl(pnIdGrupaGest,0))
				amessagebox("Nu ati ales grupa de gestiuni!",48,"Atentie")
				Thisform.ct_clb_grupa_gest.SetFocus()
				plReturn = .F.
			Case !Between(Nvl(pnProcent,-1),0.00,100)
				amessagebox("Procentul trebuie sa fie intre 0.00 si 100!",48,"Atentie")
				Thisform.clb_procent.SetFocus()
				plReturn = .F.
			Otherwise
				plReturn=.T.
		Endcase
		Return plReturn
		
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Thisform.clb_procent.text_simplu1.Value = 0
		Thisform.clb_procent.Visible = .F.
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_vanz_cant AS _frmbase OF "..\comun\clase\_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="grd_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cNume_gestiune.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cNume_gestiune.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cSubgrupa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cSubgrupa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStoci.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStoci.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cVanzari.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cVanzari.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStocF.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStocF.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cCantitate.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cCantitate.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cProcent.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cProcent.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStocDepozit.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cStocDepozit.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cValidat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cValidat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cValidat.Check1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cIntrari.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cIntrari.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_nou1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Cmd_executa2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="spnRotund" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modiparam1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_salveaza1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_grupa
		*m: savecantitati
		*p: ncantold
		*p: nid
		*p: nidcomrapvanz
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 500
		Name = "frm_rap_vanz_cant"
		ncantold = 0
		nidcomrapvanz = 0
		Width = 730
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="nidcomrapvanz" display="nIdComRapVanz"/>
		</VFPData>
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 732
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 612
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Visible = .T.
		_shape2.Width = 119
		Lb_titlu_alb_b121.Caption = "VÂNZARI PERIOADA"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 4
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 699
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 2
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Left = 0
		GRIDSORT1.Name = "GRIDSORT1"
		GRIDSORT1.Top = 504
	*</PropValue>

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

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

	ADD OBJECT 'But_modiparam1' AS but_modiparam WITH ;
		Anchor = 9, ;
		Left = 516, ;
		Name = "But_modiparam1", ;
		ToolTipText = "Importa cantitate salvata anterior (in caz de eroare)", ;
		Top = 0
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

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

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

	ADD OBJECT 'But_salveaza1' AS but_salveaza WITH ;
		Anchor = 9, ;
		Left = 546, ;
		Name = "But_salveaza1", ;
		ToolTipText = "Salveaza cantitatile introduse nevalidate, pentru import in caz de eroare", ;
		Top = 0
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_executa1' AS cmd_executa WITH ;
		Caption = "\<Completeaza cant. cu vanzarea", ;
		FontBold = .T., ;
		FontSize = 8, ;
		Height = 33, ;
		Left = 12, ;
		Name = "Cmd_executa1", ;
		ToolTipText = "Completeaza cantitate comandata cu cantitatea vanduta", ;
		Top = 36, ;
		Width = 105, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'Cmd_executa2' AS cmd_executa WITH ;
		Caption = "Rotunjeste cant. la multiplu de...", ;
		FontBold = .T., ;
		FontSize = 8, ;
		Height = 33, ;
		Left = 124, ;
		Name = "Cmd_executa2", ;
		ToolTipText = "Rotunjeste cantitatea comandata la multiplu de...", ;
		Top = 36, ;
		Width = 105, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grd_raport' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 11, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		HeaderHeight = 33, ;
		Height = 422, ;
		Left = 12, ;
		Name = "grd_raport", ;
		Panel = 1, ;
		ReadOnly = .T., ;
		RecordSource = "crscantitati", ;
		TabIndex = 1, ;
		Top = 72, ;
		Width = 708, ;
		Column1.ControlSource = "nume_gestiune", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cNume_gestiune", ;
		Column1.ReadOnly = .T., ;
		Column1.Width = 102, ;
		Column2.ControlSource = "subgrupa", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cSubgrupa", ;
		Column2.ReadOnly = .T., ;
		Column2.Width = 116, ;
		Column3.ControlSource = "denumire", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "cDenumire", ;
		Column3.ReadOnly = .T., ;
		Column3.Width = 112, ;
		Column4.ControlSource = "stoci", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.InputMask = (get_mask(14,gnPCant)), ;
		Column4.Name = "cStoci", ;
		Column4.ReadOnly = .T., ;
		Column5.ColumnOrder = 6, ;
		Column5.ControlSource = "vanzari", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.InputMask = (get_mask(14,gnPCant)), ;
		Column5.Name = "cVanzari", ;
		Column5.ReadOnly = .T., ;
		Column6.ColumnOrder = 7, ;
		Column6.ControlSource = "stocf", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.InputMask = (get_mask(14,gnPCant)), ;
		Column6.Name = "cStocF", ;
		Column6.ReadOnly = .T., ;
		Column7.ColumnOrder = 8, ;
		Column7.ControlSource = "cantitate", ;
		Column7.FontName = "Arial Narrow", ;
		Column7.InputMask = (get_mask(14,gnPCant)), ;
		Column7.Name = "cCantitate", ;
		Column7.ReadOnly = .F., ;
		Column8.ColumnOrder = 9, ;
		Column8.ControlSource = "IIF(stoci=0,NULL,ROUND(vanzari/stoci,4)*100)", ;
		Column8.FontName = "Arial Narrow", ;
		Column8.InputMask = (get_mask(14,2)), ;
		Column8.Name = "cProcent", ;
		Column8.ReadOnly = .T., ;
		Column8.Width = 41, ;
		Column9.ColumnOrder = 10, ;
		Column9.ControlSource = "stocdep", ;
		Column9.FontName = "Arial Narrow", ;
		Column9.InputMask = (get_mask(14,gnPCant)), ;
		Column9.Name = "cStocDepozit", ;
		Column9.ReadOnly = .T., ;
		Column10.ColumnOrder = 11, ;
		Column10.ControlSource = "validat", ;
		Column10.CurrentControl = "Check1", ;
		Column10.FontName = "Arial Narrow", ;
		Column10.Name = "cValidat", ;
		Column10.ReadOnly = .T., ;
		Column10.Sparse = .F., ;
		Column10.Width = 33, ;
		Column11.ColumnOrder = 5, ;
		Column11.ControlSource = "stocf-stoci+vanzari", ;
		Column11.FontName = "Arial Narrow", ;
		Column11.InputMask = (get_mask(14,gnPCant)), ;
		Column11.Name = "cIntrari", ;
		Column11.ReadOnly = .T.
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

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

	ADD OBJECT 'grd_raport.cCantitate.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 'grd_raport.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.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 'grd_raport.cIntrari.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Intrari", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cIntrari.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 'grd_raport.cNume_gestiune.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Gestiune", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cNume_gestiune.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 'grd_raport.cProcent.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Procent", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cProcent.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 'grd_raport.cStocDepozit.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Stoc depozit", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cStocDepozit.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 'grd_raport.cStocF.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Stoc final", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cStocF.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 'grd_raport.cStoci.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Stoc initial", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cStoci.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 'grd_raport.cSubgrupa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Subgrupa", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cSubgrupa.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 'grd_raport.cValidat.Check1' AS checkbox WITH ;
		Alignment = 2, ;
		Caption = "", ;
		FontName = "Arial Narrow", ;
		Height = 17, ;
		Left = 30, ;
		Name = "Check1", ;
		ReadOnly = .T., ;
		Top = 67, ;
		Width = 60
		*< END OBJECT: BaseClass="checkbox" />

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

	ADD OBJECT 'grd_raport.cValidat.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 'grd_raport.cVanzari.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Vanzari (dbl. click pt. detalii)", ;
		FontName = "Arial Narrow", ;
		Name = "Header1", ;
		WordWrap = .T.
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cVanzari.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 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grd_raport, ;
		Left = 660, ;
		Name = "Gridextra1", ;
		Top = 480
		*< END OBJECT: ClassLib="..\comun\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'spnRotund' AS _spinner WITH ;
		Height = 24, ;
		Left = 233, ;
		Name = "spnRotund", ;
		Top = 40, ;
		Value = 10, ;
		Width = 58
		*< END OBJECT: ClassLib="..\comun\clase\_baza.vcx" BaseClass="spinner" />
	
	PROCEDURE do_adauga
		Local lcXMLArticole,lcXMLGestiuni,lcCursorArt,lcCursorGest
		lcCursorArt = Sys(2015)
		lcCursorGest = Sys(2015)
		lcXMLArticole = caut_articol(,,.T.,,,,gnIdGrupaArtSectie)
		If !Empty(lcXMLArticole) And gnButon = 1
			Xmltocursor(lcXMLArticole,lcCursorArt)
			If Reccount(lcCursorArt) = 0
				amessagebox("Nu ati ales articolul / articolele!",48,"Atentie")
			Else
		
				lcSelect = [select nume_gestiune,cgest,id_gestiune,nr_pag,cont from nom_gestiuni]
				lcFiltru = []
				lcSchema = [nume_gestiune C(50),cgest C(20),id_gestiune N(5),nr_pag N(2),cont C(4)]
				lcOrder = [nume_gestiune]
				lcColoana = [nume_gestiune,cgest,nr_pag,cont]
				lcTitluColoana = [Nume, Cgest, Nr.pag, Cont]
				lcTitlu = [Alegeti gestiunea (mouse-click pe nume sau apasati SPACE)]
				lcNume_Proc = []
				llAllInList = .F.
				lcFiltruOriginal = [sters = 0 and id_gestiune in (select id_gestiune from gest_coresp_grupe_gestiuni where sters = 0 and id_grupe in ] + ;
					[(select id_grupe from comrapvanz where id_comrapvanz = ] + Alltrim(Str(Thisform.nIdComRapVanz)) + [))]
				lcPrimaColoana = [nume_gestiune]
				lnPornire = 1
				lnTipReturn = 1
				lcIdColumn = [id_gestiune]
				lcXMLGestiuni = cauta_alfa(lcSelect,lcFiltru,lcSchema,lcOrder,lcColoana,lcTitlu,lcTitluColoana,lcNume_Proc,llAllInList,;
					lcFiltruOriginal,lcPrimaColoana, lnPornire, lnTipReturn, lcIdColumn)
		
				If !Empty(lcXMLGestiuni) And gnButon = 1
					Xmltocursor(lcXMLGestiuni,lcCursorGest)
					If Reccount(lcCursorGest) = 0
						amessagebox("Nu ati ales gestiunea / gestiunile!",48,"Atentie")
					Else
						lcCursor = Thisform.grd_raport.RecordSource
						Thisform.LockScreen = .T.
						Thisform.grd_raport.salveaza_grid()
						completeaza_rap_vanz_per(Thisform.nIdComRapVanz,lcCursorArt,lcCursorGest,lcCursor)
						Thisform.grd_raport.incarca_grid()
						Thisform.LockScreen = .F.
					Endif
				Endif
			Endif
		Endif
		Use In (Select(lcCursorArt))
		Use In (Select(lcCursorGest))
		Release lcXMLArticole,lcXMLGestiuni,lcCursorArt,lcCursorGest
	ENDPROC

	PROCEDURE do_cauta_grupa
	ENDPROC

	PROCEDURE do_excel
		lnOptiune = xmenu('Comenzi pe \<furnizori - vanzari')
		llExcel = .T.
		llCantitate = .F.
		THIS.AlwaysOnTop = .F.
		DO listeaza_rap_vanz_fz_per WITH Thisform.nIdComRapVanz, m.llCantitate, m.llExcel 
		THIS.AlwaysOnTop = .T.
		
		
	ENDPROC

	PROCEDURE do_listare
		lnOptiune = xmenu('Comenzi pe \<furnizori - vanzari')
		llExcel = .F.
		llCantitate = .F.
		THIS.AlwaysOnTop = .F.
		DO listeaza_rap_vanz_fz_per WITH Thisform.nIdComRapVanz, m.llCantitate, m.llExcel 
		THIS.AlwaysOnTop = .T.
		
		
	ENDPROC

	PROCEDURE do_salvare
		lcFile = This.Savecantitati()
		IF !EMPTY(m.lcFile)
			AMESSAGEBOX('S-au salvat datele in fisierul ' + TRANSFORM(m.lcFile), 0+64, _Screen.Caption)
		ELSE
			AMESSAGEBOX('NU s-au salvat datele!', 0+64, _Screen.Caption)
		ENDIF 	
	ENDPROC

	PROCEDURE inainte_de_do_renunt
		This.SaveCantitati()
		DODEFAULT()
	ENDPROC

	PROCEDURE inainte_de_do_termin
		* Se salveaza cantitatile completate si se genereaza comenzi
		PRIVATE pnIdComRapVanz, pcXmlCantitati, pnNrComenzi
		pnNrComenzi = 0
		pcXmlCantitati = ''
		Local llReturn, lcSql, lnSucces, lcCursor, lcCursor2, lcListaCantitati, lnNrInreg, lnRecords
		llReturn = .F.
		lcCursor = Thisform.grd_raport.RecordSource
		lcCursor2 = [crsRaportTemp]
		lcListaCantitati = []
		pnIdComRapVanz = Thisform.nIdComRapVanz
		
		This.SaveCantitati()
		
		Select (lcCursor)
		lnNrInreg = Recno()
		SELECT id_comrapvanzelem as id, cantitate FROM (lcCursor) WHERE cantitate <> 0 AND NVL(validat,1) = 0 INTO CURSOR crsraportvanzari
		lnRecords = _tally
		CURSORTOXML('crsraportvanzari', 'pcXmlCantitati',1,1,0,"1")
		*!*	IF Debug_Start()
		*!*		STRTOFILE('pnIdComRapVanz: ' + ALLTRIM(STR(pnIdComRapVanz)) + CHR(13) + CHR(10) + pcXMLCantitati,PUTFILE('Fisier','xmlcantitati','txt'),0)
		*!*	ENDIF 
		USE IN (SELECT('crsraportvanzari'))
		
		If m.lnRecords > 0
		*!*		lcSql = [{call pack_comenzi.actualizeaza_raport(]+Alltrim(Str(Thisform.nIdComRapVanz))+[,'] + lcListaCantitati + [')}]
			lcSql = [{call pack_comenzi.actualizeaza_raport(?pnIdComRapVanz,?pcXmlCantitati,?@pnNrComenzi)}]
			lnSucces = goExecutor.oExecute(m.lcSql,m.lcCursor2)
			If lnSucces < 0
				amessagebox(goExecutor.cEroare,0+48,"Eroare")
			Else
				If Reccount(m.lcCursor2) > 0
					loFrm = Createobject("frm_rap_vanz_verificari")
					loFrm.Show()
				Else
					AMESSAGEBOX('S-au generat ' + ALLTRIM(STR(NVL(m.pnNrComenzi,0))) + ' comenzi.',0+64,_screen.Caption)
					llReturn = .T.
				Endif
			ENDIF
			
			Use In (select(m.lcCursor2))	
		ELSE 
			AMESSAGEBOX('Nu exista cantitati modificate. Nu s-au generat comenzi.',0+64, _screen.Caption)
			llReturn = .T.
		Endif
		Release pcXmlCantitati
		
		SELECT (lcCursor)
		GO lnNrInreg
		
		Return llReturn
	ENDPROC

	PROCEDURE Init
		Lparameters ttDataI,ttDataS,tnIdComRapVanz
		DoDefault()
		Thisform.nIdComRapVanz = tnIdComRapVanz
		Thisform.lb_titlu_alb_b121.Caption = [VANZARI PERIOADA ] + Ttoc(ttDataI) + [ - ] + Ttoc(ttDataS)
		Thisform.grd_raport.cCantitate.DynamicBackColor = [Iif(validat = 1, RGB(200,200,200), IIF(cantitate=0,Rgb(255,255,0),Rgb(39,233,243)))]
		Thisform.grd_raport.cCantitate.ReadOnly = .F.
		Thisform.gridextra1.Setup()
		This.grd_raport.HeaderHeight = 33
	ENDPROC

	PROCEDURE savecantitati
		** Export modificarile din cursor, in caz ca se intampla vreo eroare
		*** pot sa import xml si sa actualizez cantitatile
		LOCAL lcFile, lcCursor
		lcFile = gcTempPath + 'rap_vanz_cant_' + ALLTRIM(STR(gnAn)) + '_' + PADL(gnLuna,2,'0') + '_' + TTOC(DATETIME(),1) + '.xml'
		lcCursor = Thisform.grd_raport.RecordSource
		SELECT * FROM (lcCursor) WITH (buffering = .T.) WHERE cantitate <> 0 And NVL(Validat,0) = 0 INTO CURSOR cRapVanzCantTemp
		CURSORTOXML('cRapVanzCantTemp', lcFile,1,0+512,0,"1")
		USE IN (SELECT('cRapVanzCantTemp'))
		RETURN m.lcFile
	ENDPROC

	PROCEDURE But_modiparam1.Click
		SET STEP ON 
		Local lcFile, lnCantitate, lnIdArticol, lnStocDep, lnId, lnIdGestiune 
		Cd (gcTempPath)
		lcFile = Getfile('xml', 'Fisier xml', 'Alege', 0, 'Fisier xml salvare anterioara "rap_vanz_cant_' + Alltrim(Str(gnAn)) + '_' + Padl(gnLuna,2, '0') + '_*.xml"')
		If !Empty(m.lcFile)
			If AMESSAGEBOX('Doriti sa suprascrieti cantitatea comandata din tabel cu cea din fisier?',4+32,_Screen.Caption) = 6
				Xmltocursor(m.lcFile, "cRapVanzCantTemp", 512)
				If Used("cRapVanzCantTemp")
					IF !(TYPE('cRapVanzCantTemp.id_comrapvanzelem') = 'N' AND TYPE('cRapVanzCantTemp.id_articol') = 'N' AND TYPE('cRapVanzCantTemp.id_gestiune') = 'N' AND TYPE('cRapVanzCantTemp.cantitate') = 'N' AND TYPE('cRapVanzCantTemp.stocdep') = 'N')
						AMESSAGEBOX('Fisierul nu este de tipul corect!',0+48,_screen.Caption)
					ELSE 	
						Select cRapVanzCantTemp
						lnRecc = RECCOUNT()
						SCAN
							lnCantitate = cantitate
							lnStocDep = stocdep
							lnIdArticol = id_articol
							lnIdGestiune = id_gestiune
							lnId = id_comrapvanzelem
							lnRecno = RECNO()
							IF MOD(RECNO(), 100) = 0
								WAIT WINDOW 'Completare cantitati ' + TRANSFORM(lnRecno) + ' / ' + TRANSFORM(lnRecc) NOWAIT 
							ENDIF 
							Update crsCantitati Set cantitate = m.lnCantitate, stocdep = m.lnStocDep Where id_comrapvanzelem = lnId
						ENDSCAN
					ENDIF 	
				ENDIF
				Use In (Select("cRapVanzCantTemp"))
			Endif
		Endif
		
	ENDPROC

	PROCEDURE Cmd_executa1.Click
		SELECT crsCantitati
		REPLACE ALL cantitate WITH vanzari FOR validat = 0
		GO TOP 
		Thisform.grd_raport.SetFocus()
		
		
	ENDPROC

	PROCEDURE Cmd_executa2.Click
		lnRotund = thisform.spnRotund.Value
		SELECT crsCantitati
		REPLACE ALL cantitate WITH INT(cantitate/m.lnRotund)*lnRotund + IIF(MOD(cantitate, m.lnRotund) = 0, 0, m.lnRotund) FOR validat = 0
		GO TOP 
		Thisform.grd_raport.SetFocus()
		
		
	ENDPROC

	PROCEDURE grd_raport.cCantitate.Text1.Valid
		*!* 04.04.2016
		*!* marius.mutut
		*!* Se verifica daca s-a introdus o valoare prea mare. Apare eroare la inregistrarea in baza de date
		
		Local lnDiferenta, lnIdArticol, lnRec
		lnRec = RECNO('crsCantitati')
		IF this.Value > 1000000
			AMESSAGEBOX('Ati introdus o valoare prea mare!',0+48,_screen.Caption)
			RETURN .F.
		ENDIF 	
		lnDiferenta = (Thisform.nCantOld - this.Value)
		IF lnDiferenta <> 0
			thisform.LockScreen=.T.
			lnIdArticol = crsCantitati.id_articol
			UPDATE crsCantitati SET stocdep = stocdep + m.lnDiferenta WHERE id_articol = lnIdArticol
			GOTO lnRec IN crsCantitati
			thisform.LockScreen=.F.
		ENDIF
	ENDPROC

	PROCEDURE grd_raport.cCantitate.Text1.When
		* nu permit modificarea cantitatilor care deja s-au transformat in comenzi
		IF NVL(crsCantitati.validat,0) = 1 
			RETURN
		ENDIF 
		Thisform.nCantOld = this.Value 
	ENDPROC

	PROCEDURE grd_raport.cVanzari.Text1.DblClick
		LOCAL lnId
		lnId = NVL(crsCantitati.id_comRapVanzElem, 0)
		IF !EMPTY(lnId)
			DO rap_vanz_per_detaliu WITH m.lnId
		ENDIF 	
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_vanz_cant_detaliu AS _frmbase OF "..\comun\clase\_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="grd_raport_detaliu" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cNume_gestiune.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cNume_gestiune.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cSubgrupa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cSubgrupa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cStoci.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cStoci.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cVanzari.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cVanzari.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cStocF.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport_detaliu.cStocF.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_grupa
		*p: ncantold
		*p: nid
		*p: nidcomrapvanz
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		BorderStyle = 1
		DoCreate = .T.
		Height = 298
		Name = "frm_rap_vanz_cant_detaliu"
		ncantold = 0
		nidcomrapvanz = 0
		Width = 730
		_memberdata = <VFPData>
			<memberdata name="nidcomrapvanz" display="nIdComRapVanz"/>
		</VFPData>
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 732
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 696
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Visible = .T.
		_shape2.Width = 35
		Lb_titlu_alb_b121.Caption = "VÂNZARI PERIOADA DETALIU"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 4
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 699
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 2
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'grd_raport_detaliu' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 6, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		Height = 252, ;
		Left = 12, ;
		Name = "grd_raport_detaliu", ;
		Panel = 1, ;
		RecordSource = "crsCantitatiDetaliu", ;
		TabIndex = 1, ;
		Top = 36, ;
		Width = 708, ;
		Column1.ControlSource = "nume_gestiune", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cNume_gestiune", ;
		Column1.Width = 102, ;
		Column2.ControlSource = "subgrupa", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cSubgrupa", ;
		Column2.Width = 116, ;
		Column3.ControlSource = "denumire", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "cDenumire", ;
		Column3.Width = 112, ;
		Column4.ColumnOrder = 5, ;
		Column4.ControlSource = "dataora", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.InputMask = "", ;
		Column4.Name = "cStoci", ;
		Column4.Width = 94, ;
		Column5.ColumnOrder = 4, ;
		Column5.ControlSource = "vanzari", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.InputMask = (get_mask(14,gnPCant)), ;
		Column5.Name = "cVanzari", ;
		Column6.ControlSource = "utilizator", ;
		Column6.FontName = "Arial Narrow", ;
		Column6.InputMask = "", ;
		Column6.Name = "cStocF", ;
		Column6.Width = 139
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

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

	ADD OBJECT 'grd_raport_detaliu.cDenumire.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 'grd_raport_detaliu.cNume_gestiune.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Gestiune", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport_detaliu.cNume_gestiune.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 'grd_raport_detaliu.cStocF.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Utilizator", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport_detaliu.cStocF.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 'grd_raport_detaliu.cStoci.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Dataora", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport_detaliu.cStoci.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 'grd_raport_detaliu.cSubgrupa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Subgrupa", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport_detaliu.cSubgrupa.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 'grd_raport_detaliu.cVanzari.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Vanzari", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport_detaliu.cVanzari.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 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grd_raport_detaliu, ;
		Left = 708, ;
		Name = "Gridextra1", ;
		Top = 264
		*< END OBJECT: ClassLib="..\comun\utile\gridextras\gridextras.vcx" BaseClass="custom" />
	
	PROCEDURE do_cauta_grupa
	ENDPROC

	PROCEDURE Init
		DODEFAULT()
		this.gridextra1.setup()
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_vanz_centr AS _frmbase OF "..\comun\clase\_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="grd_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataI.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataI.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataS.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataS.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cNume_grupa.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cNume_grupa.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataora.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDataora.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cUtilizator.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cUtilizator.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_listare1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_sterge1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_modifica1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_grupa
		*m: do_raport
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 500
		Name = "frm_rap_vanz_centr"
		Width = 700
		WindowState = 2
		_memberdata = <VFPData>
			<memberdata name="ntip" display="nTip"/>
		</VFPData>
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 700
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 665
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Width = 64
		Lb_titlu_alb_b121.Caption = "Centralizator rapoarte comenzi bazate pe vanzari"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 6
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 668
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

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

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

	ADD OBJECT 'But_modifica1' AS but_modifica WITH ;
		Anchor = 9, ;
		Left = 548, ;
		Name = "But_modifica1", ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

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

	ADD OBJECT 'grd_raport' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 5, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		Height = 445, ;
		Left = 12, ;
		Name = "grd_raport", ;
		Panel = 1, ;
		RecordSource = "crsrapoarte", ;
		TabIndex = 3, ;
		Top = 43, ;
		Width = 672, ;
		Column1.ControlSource = "datai", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cDataI", ;
		Column1.Width = 102, ;
		Column2.ControlSource = "datas", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cDataS", ;
		Column2.Width = 116, ;
		Column3.ControlSource = "nume_grupa", ;
		Column3.FontName = "Arial Narrow", ;
		Column3.Name = "cNume_grupa", ;
		Column3.Width = 214, ;
		Column4.ControlSource = "dataora", ;
		Column4.FontName = "Arial Narrow", ;
		Column4.Name = "cDataora", ;
		Column4.Width = 89, ;
		Column5.ControlSource = "utilizator", ;
		Column5.FontName = "Arial Narrow", ;
		Column5.Name = "cUtilizator", ;
		Column5.Width = 114
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

	ADD OBJECT 'grd_raport.cDataI.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data inceput", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cDataI.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 'grd_raport.cDataora.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data raport", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cDataora.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 'grd_raport.cDataS.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Data sfarsit", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cDataS.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 'grd_raport.cNume_grupa.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Grupa gestiuni", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cNume_grupa.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 'grd_raport.cUtilizator.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Utilizator", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cUtilizator.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 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grd_raport, ;
		Left = 664, ;
		Name = "Gridextra1", ;
		Top = 473
		*< END OBJECT: ClassLib="..\comun\utile\gridextras\gridextras.vcx" BaseClass="custom" />
	
	PROCEDURE do_cauta_grupa
	ENDPROC

	PROCEDURE do_excel
		This.do_raport(.T.)
	ENDPROC

	PROCEDURE do_listare
		This.do_raport(.F.)
	ENDPROC

	PROCEDURE do_modifica
		Local lnIdComRapVanz
		Local ltDataI, ltDataS
		lnIdComRapVanz = crsRapoarte.id_comrapvanz
		ltDataI = crsRapoarte.datai
		ltDataS = crsRapoarte.DataS
		If Empty(Nvl(lnIdComRapVanz, 0))
			Return
		Endif
		This.AlwaysOnTop = .F.
		genereaza_rap_vanz_per(m.lnIdComRapVanz, m.ltDataI, m.ltDataS)
		This.AlwaysOnTop = .T.
	ENDPROC

	PROCEDURE do_raport
		Lparameters tlExportExcel
		
		Local llExportExcel, lnIdComRapVanz, lnTip
		llExportExcel = m.tlExportExcel
		lnIdComRapVanz = crsRapoarte.id_comrapvanz
		If Empty(Nvl(lnIdComRapVanz, 0))
			Return
		Endif
		
		lnOptiune = xmenu("\<Comenzi pe gestiuni detaliat;" + ;
			"\-;" + ;
			"Comenzi pe \<furnizori - comanda;" + ;
			"Comenzi pe \<furnizori - vanzari;" + ;
			"\-;" + ;
			"Comenzi pe furnizori \<valoric - comanda;" + ;
			"Comenzi pe furnizori \<valoric - vanzari")
		This.AlwaysOnTop = .F.
		Do Case
			Case m.lnOptiune = 1
				listeaza_rap_vanz_per(m.lnIdComRapVanz, m.llExportExcel)
			Case m.lnOptiune = 3
				llCantitate = .T.
				listeaza_rap_vanz_fz_per(m.lnIdComRapVanz, m.llCantitate, m.llExportExcel)
			Case m.lnOptiune = 4
				llCantitate = .F.
				listeaza_rap_vanz_fz_per(m.lnIdComRapVanz, m.llCantitate, m.llExportExcel)
			Case m.lnOptiune = 6
				llCantitate = .T.
				listeaza_rap_vanz_fz_val_per(m.lnIdComRapVanz, m.llCantitate, m.llExportExcel)
			Case m.lnOptiune = 7
				llCantitate = .F.
				listeaza_rap_vanz_fz_val_per(m.lnIdComRapVanz, m.llCantitate, m.llExportExcel)
		Endcase
		This.AlwaysOnTop = .T.
		
	ENDPROC

	PROCEDURE do_sterge
		Local lnIdComRapVanz
		lnIdComRapVanz = crsRapoarte.id_comrapvanz
		If Empty(Nvl(lnIdComRapVanz, 0))
			Return
		Endif
		IF AMESSAGEBOX('Doriti sa stergeti raportul?',4+32,_screen.Caption) = 6
			IF AMESSAGEBOX('Operatia este definitiva. Doriti sa stergeti raportul?',4+32,_screen.Caption) = 6
				llSucces = sterg_rap_vanz_per(m.lnIdComRapVanz)
				IF m.llSucces
					SELECT crsRapoarte
					DELETE 
					LOCATE 
					this.grd_raport.SetFocus()
				ENDIF 
			ENDIF 	
		ENDIF 	
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Thisform.gridextra1.Setup()
		
	ENDPROC

ENDDEFINE

DEFINE CLASS frm_rap_vanz_verificari AS _frmbase OF "..\comun\clase\_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="grd_raport" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDenumire.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cDenumire.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cCodMat.Header1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="grd_raport.cCodMat.Text1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Gridextra1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lb_explicatie" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="But_excel1" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: do_cauta_grupa
		*p: nid
		*p: orec
	*</DefinedPropArrayMethod>

	*<PropValue>
		DoCreate = .T.
		Height = 500
		Name = "frm_rap_vanz_verificari"
		Width = 700
		_shape1.Anchor = 11
		_shape1.Height = 29
		_shape1.Left = 0
		_shape1.Name = "_shape1"
		_shape1.Top = 0
		_shape1.Width = 700
		_shape2.Anchor = 9
		_shape2.Height = 29
		_shape2.Left = 624
		_shape2.Name = "_shape2"
		_shape2.Top = 0
		_shape2.Visible = .T.
		_shape2.Width = 76
		Lb_titlu_alb_b121.Caption = "VERIFICARE PRETURI"
		Lb_titlu_alb_b121.FontBold = .T.
		Lb_titlu_alb_b121.Name = "Lb_titlu_alb_b121"
		Lb_titlu_alb_b121.TabIndex = 6
		BUT_TERMIN1.Anchor = 9
		BUT_TERMIN1.Left = 668
		BUT_TERMIN1.Name = "BUT_TERMIN1"
		BUT_TERMIN1.TabIndex = 4
		BUT_TERMIN1.Top = 1
		GRIDSORT1.Name = "GRIDSORT1"
	*</PropValue>

	ADD OBJECT 'But_excel1' AS but_excel WITH ;
		Left = 628, ;
		Name = "But_excel1", ;
		Top = 1
		*< END OBJECT: ClassLib="..\comun\clase\cmd_butoane.vcx" BaseClass="commandbutton" />

	ADD OBJECT 'grd_raport' AS _grdrow WITH ;
		Anchor = 15, ;
		ColumnCount = 2, ;
		DeleteMark = .F., ;
		FontName = "Arial Narrow", ;
		Height = 416, ;
		Left = 12, ;
		Name = "grd_raport", ;
		Panel = 1, ;
		RecordSource = "crsRaportTemp", ;
		TabIndex = 3, ;
		Top = 72, ;
		Width = 672, ;
		Column1.ControlSource = "denumire", ;
		Column1.FontName = "Arial Narrow", ;
		Column1.Name = "cDenumire", ;
		Column1.Width = 246, ;
		Column2.ControlSource = "codmat", ;
		Column2.FontName = "Arial Narrow", ;
		Column2.Name = "cCodMat", ;
		Column2.Width = 114
		*< END OBJECT: ClassLib="..\comun\clase\_grd_base.vcx" BaseClass="grid" />

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

	ADD OBJECT 'grd_raport.cCodMat.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 'grd_raport.cDenumire.Header1' AS header WITH ;
		Alignment = 2, ;
		Caption = "Denumire", ;
		FontName = "Arial Narrow", ;
		Name = "Header1"
		*< END OBJECT: BaseClass="header" />

	ADD OBJECT 'grd_raport.cDenumire.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 'Gridextra1' AS gridextra WITH ;
		gridexpression = Thisform.grd_raport, ;
		Left = 588, ;
		Name = "Gridextra1", ;
		Top = 492
		*< END OBJECT: ClassLib="..\comun\utile\gridextras\gridextras.vcx" BaseClass="custom" />

	ADD OBJECT 'lb_explicatie' AS lb_simplu WITH ;
		Caption = "     Articolele de mai jos nu au pret / au pretul 0 in politica de preturi implicita pentru comenzile de la gestiuni. Pentru a putea genera comanda trebuie sa le introduceti preturile.", ;
		Height = 32, ;
		Left = 55, ;
		Name = "lb_explicatie", ;
		Top = 36, ;
		Width = 588, ;
		WordWrap = .T.
		*< END OBJECT: ClassLib="..\comun\clase\lb.vcx" BaseClass="label" />
	
	PROCEDURE do_cauta_grupa
	ENDPROC

	PROCEDURE do_excel
		goExport.export2xls(Thisform.grd_raport.RecordSource)
	ENDPROC

	PROCEDURE Init
		DoDefault()
		Thisform.gridextra1.Setup()
		
	ENDPROC

ENDDEFINE
