*!* 22.03.2010
*!* marius.mutu
*!* nom_Gestiuni_nou, nom_gestiuni_modifica (ccsectii - completare cursor sectii)

*!*	31.01.2017
*!*	marius.mutu
*!*	nom_gestiuni_nou + tnIdGestiune (optional): daca se doreste crearea unei gestiuni prin copierea unei alte gestiuni (tnIdGestiune)

*!* 07.01.2020
*!* marius.mutu
*!* contracte_nou, articole_nou + @tnId pentru returnarea id-ului inregistrarii nou create

*!*	03.03.2026
*!*	marius.mutu
*!*	nom_parteneri_nou - completare nume si prenume din denumire daca nu sunt completate, pentru persoana fizica

* PROCEDURE viz_lucrari	(  )
* Date : 07.10.2004, 14:26:02
* author : marius.mutu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_lucrari *******************************************
Procedure viz_lucrari(  )

	Private polucrari, pcschema1, pcselect1
	Store '' To polucrari
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_lucrari where 1=2']
	pcorder1 = [nrord]
	pcfiltru1 = [1=2]
	llAfiseaza = .F.
	gencursor('polucrari', 'v_nom_lucrari', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	polucrari.ca_baza1.afisare()
	ofrmsectii = Createobject('frm_lucrari')
	ofrmsectii.Show(1)
	Release polucrari

Endproc
******************************************* SFARSIT: viz_lucrari*******************************************

* PROCEDURE viz_sectii(  )
* Date : 07.10.2004, 14:26:02
* author : catalin.neagu
* description:
******************************************* INCEPUT:viz_sectii *******************************************
Procedure viz_sectii(  )

	Private posectii, pcschema1, pcselect1
	Store '' To posectii
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_sectii where 1=2']
	pcorder1 = [sectie]
	pcfiltru1 = [2=2] + gcCondSucursala
	llAfiseaza = .F.
	gencursor('posectii', 'v_sectii', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	posectii.ca_baza1.afisare()
	ofrmsectii = Createobject('frm_sectii')
	ofrmsectii.Show(1)
	Release posectii

Endproc
******************************************* SFARSIT: viz_sectii *******************************************

* PROCEDURE viz_sucursale(  )
* Date : 25.08.2005
* author : marius.mutu
* description:
******************************************* INCEPUT:viz_sectii *******************************************
Procedure viz_sucursale(  )

	Private posucursale, pcschema1, pcselect1
	Store '' To posucursale
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_sucursale where 1=2']
	pcorder1 = [sucursala]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('posucursale', 'v_sucursale', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	posucursale.ca_baza1.afisare()
	ofrmsucursale = Createobject('frm_sucursale')
	ofrmsucursale.Show(1)
	Release posucursale

Endproc
******************************************* SFARSIT: viz_sectii *******************************************

* PROCEDURE viz_gestiuni(  )
* Date : 07.10.2004, 16:07:41
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_gestiuni *******************************************
Procedure viz_gestiuni(  )

	Private pogestiuni, pcschema1, pcselect1
	Store '' To pogestiuni
	*!*	pcschema1=['id_gestiune n(5),nume_gestiune c(50),cgest c(4),cont_gestiune c(4),ngest c(10),nrg n(4),ascd c(4),nr_grupa n(4),gest n(3)']
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_gestiuni where 1=2']
	pcorder1 = [nume_gestiune]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pogestiuni', 'v_gestiuni', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pogestiuni.ca_baza1.afisare()
	ofrmgest = Createobject('frm_gestiuni')
	ofrmgest.Show(1)
	Release posectii

Endproc
******************************************* SFARSIT: viz_gestiuni *******************************************

* PROCEDURE viz_responsabili(  )
* Date : 08.10.2004, 14:24:55
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_responsabili *******************************************
Procedure viz_responsabili(  )

	Private poresponsabili, pcschema1, pcselect1
	Store '' To poresponsabili
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_responsabili where 1=2']
	pcorder1 = [nume]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poresponsabili', 'v_responsabili', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poresponsabili.ca_baza1.afisare()
	ofrmres = Createobject('frm_responsabili')
	ofrmres.Show(1)
	Release poresponsabili


Endproc
******************************************* SFARSIT: viz_responsabili *******************************************

* PROCEDURE viz_venchel(  )
* Date : 08.10.2004, 15:48:26
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_venchel *******************************************
Procedure viz_venchel(  )

	&&code goes here
	Private povenchel, pcschema1, pcselect1
	Store '' To povenchel
	pcschema1 = ['id_venchelt n(10),id_tata n(10),tip_venchelt n(1),explicatie c(200),'+] + ;
		['explicatie_fiu c(50),explicatie_tata c(50),inactiv n(1),id_mod n(20)']
	pcselect1 = ['select id_venchelt,id_tata,tip_venchelt,explicatie,'+] + ;
		['explicatie_fiu,explicatie_tata,inactiv,id_mod from ] + gcS + [.vnom_venchel where 1=2']
	pcorder1 = [explicatie,explicatie_fiu,explicatie_tata]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('povenchel', 'v_venchel', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	povenchel.ca_baza1.afisare()
	ofrmvenchel = Createobject('frm_venchel')
	ofrmvenchel.Show(1)
	Release povenchel

Endproc
******************************************* SFARSIT: viz_venchel *******************************************

* PROCEDURE viz_plcont(  )
* Date : 08.10.2004, 16:38:18
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_plcont *******************************************
Procedure viz_plcont(  )

	Private poplcont, pcschema1, pcselect1
	Store '' To poplcont
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_plcont where 1=2']
	pcorder1 = [AN,CONT,ACONT]
	pcfiltru1 = [an=] + Alltrim(Str(gnan))
	llAfiseaza = .F.
	gencursor('poplcont', 'v_plcont', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poplcont.ca_baza1.afisare()
	ofrmplcont = Createobject('frm_plcont')
	ofrmplcont.Show(1)
	Release poplcont


Endproc
******************************************* SFARSIT: viz_plcont *******************************************

* PROCEDURE viz_fdoc(  )
* Date : 11.10.2004, 09:41:01
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_fdoc *******************************************
Procedure viz_fdoc(  )

	Private pofdoc, pcschema1, pcselect1
	Store '' To pofdoc

	lcSchema = [ID_FDOC I, ID_FDOC2 I, FEL_DOCUMENT C(30), ID_MOD I, INACTIV I, TIP_DOC C(10), DESCRIERE C(50), PAYMENTCODE C(9), METHODCODE C(9), PAYMENTMETHOD C(110), PAYMENTNAME C(250)]
	lcSelect = [select id_fdoc, id_fdoc2, fel_document, id_mod, inactiv, tip_doc, descriere, paymentcode, methodcode, paymentmethod, paymentname from vnom_fdoc]
	lcOrder = [fel_document]
	lcFiltru = [2=2]
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []

	gencursor('pofdoc', 'v_fdoc', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	
	pofdoc.ca_baza1.afisare()
	ofrmfdoc = Createobject('frm_fdoc')
	ofrmfdoc.Show(1)
	Release pofdoc

	Use In (Select('v_fdoc'))
Endproc
******************************************* SFARSIT: viz_fdoc *******************************************

* PROCEDURE viz_judete(  )
* Date : 11.10.2004, 13:40:46
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_judete *******************************************
Procedure viz_judete(  )

	Private pojud, pcschema1, pcselect1
	Store '' To pojud

	lnSucces = update_tip_doc() && updateserver.prg
	If m.lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, _Screen.Caption)
		Create Cursor crsTipDoc394 (Id I, tip C(50))
	Endif

	pcschema1 = ['']
	pcselect1 = ['select * from syn_vnom_judete where 1=2']
	pcorder1 = [judet]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pojud', 'v_judet', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pojud.ca_baza1.afisare()
	ofrmjud = Createobject('frm_judet')
	ofrmjud.Show(1)
	Release pojud

Endproc
******************************************* SFARSIT: viz_judete *******************************************

* PROCEDURE viz_localitati(  )
* Date : 11.10.2004, 13:42:47
* author : catalin.neagu
* description:

****** PARAMETER BLOCK **************
* Parameters : 0
*
******************************************* INCEPUT:viz_localitati *******************************************
Procedure viz_localitati(  )

	Private poloc, pcschema1, pcselect1
	Store '' To poloc
	pcschema1 = ['']
	pcselect1 = ['select * from syn_vnom_localitati where 1=2']
	pcorder1 = [localitate]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poloc', 'v_local', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poloc.ca_baza1.afisare()
	ofrmloc = Createobject('frm_localitati')
	ofrmloc.Show(1)
	Release poloc

Endproc
******************************************* SFARSIT: viz_localitati *******************************************


*------------------------------------------------------------
* Description: vizualizare parteneri
* Parameters:
* Return:
* Use:
*------------------------------------------------------------
* Id Date        By         Description
*  1 26/06/2006  paula.mutu Initial Creation
*
*------------------------------------------------------------
Procedure viz_parteneri
	Lparameters tnIdTipPart, tnSpecial, tcMesaj, tcTitlu, tnTipPersoana
	*!* tnIdTipPart: tip partener care este bifat implicit
	*!* tnSpecial: tipul partener bifat nu se poate modifica de utilizator
	*!* tcMesaj:
	*!* tcTitlu: Titlu formular (Clienti/Furnizori/Agenti/Responsabili/Delegati)
	*!*	tnTipPersoana : tipul de persoana cu care intra implicit la adaugare ( 1 - juridica, 2 - fizica )


	PRIVATE poCoduri
	LOCAL lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcGroup, llModParam, lcFiltruOriginal
	Local lnIdTipPart, lnSpecial, lcMesaj, lcTitlu, lnTipPersoana
	
	poCoduri = NULL
	
	lnIdTipPart = Icase(!Empty(tnIdTipPart), tnIdTipPart, 0)
	lnSpecial = Icase(!Empty(tnSpecial), tnSpecial, 0)
	lcMesaj = Icase(!Empty(tcMesaj), tcMesaj, '')
	lcTitlu = ICASE(!EMPTY(m.tcTitlu), m.tcTitlu, '')
	lnTipPersoana = ICASE(!EMPTY(m.tnTipPersoana), m.tnTipPersoana, 1)
	
	** load cursor crscoresp_tip_parteneri gol:
	Private pocoresp_tip_parteneri, pcselect1, pcfiltru1, pcschema1, pcorder1
	Store "" To pcselect1, pcfiltru1, pcschema1, pcorder1, pocoresp_tip_parteneri
	pcselect1 = ['SELECT * FROM VCORESP_TIP_PART where 1=2']
	pcfiltru1 = [1=2]
	pcschema1 = ['']
	pcorder1 = [TIP_PARTENER]
	llAfisare1 = .F.
	gencursor('pocoresp_tip_parteneri', 'crscoresp_tip_parteneri', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfisare1)
	pocoresp_tip_parteneri.ca_baza1.afisare()

	&& adrese
	Private poAdrese, pcselect2, pcfiltru2, pcschema2, pcorder2
	Store "" To poAdrese, pcselect2, pcfiltru2, pcschema2, pcorder2
	pcselect2 = ['SELECT id_adresa, id_part, denumire_adresa, da_apare, strada, numar,  bloc, scara, etaj, apart, sector, '+] + ;
		['id_loc, localitate, id_regiune, id_judet, judet, codpostal, id_tara, tara, telefon1, telefon2, fax, email, web, '+] + ;
		['inactiv, principala  FROM ] + gcS + [.vadrese_parteneri where 1=2']
	pcfiltru2 = [1=2]
	pcschema2 = ['']
	pcorder2 = [localitate,strada]	&&	modificare adrese parteneri 12.2013 : am adaugat localitate
	llAfisare2 = .F.
	gencursor('poAdrese', 'crsAdrese', pcselect2, pcfiltru2, pcschema2, pcorder2, llAfisare2)
	poAdrese.ca_baza1.afisare()

	&& persoane de contact
	Private poPers, pcselect3, pcfiltru3, pcschema3, pcorder3
	Store "" To poPers, pcselect, pcfiltru, pcschema, pcorder
	pcselect3 = ['SELECT id_pers, id_part, nume, prenume, apelativ, functia, telefon, email, inactiv, principal  FROM ] + gcS + [.vpers_contact where 1=2']
	pcfiltru3 = [1=2]
	pcschema3 = ['']
	pcorder3 = [nume]
	llAfisare3 = .F.
	gencursor('poPers', 'crsPers_contact', pcselect3, pcfiltru3, pcschema3, pcorder3, llAfisare3)
	poPers.ca_baza1.afisare()

	&& coduri
	lcSchema = []
	lcSelect = [SELECT id,id_part, cod FROM vparteneri_coduri]
	lcFiltru = [1=2]
	lcOrder = [cod]
	llAfiseaza = .F.
	lcGroup = []
	llModParam = .T.
	lcFiltruOriginal = []
	gencursor('poCoduri', 'crsCoduri', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcGroup, llModParam, lcFiltruOriginal)
	poCoduri.ca_baza1.afisare()
	
	&& contracte
	Private poContracte
	LOCAL lcSelect4, lcFiltru4, lcSchema4, lcOrder4, llModParam4, lcFiltruOriginal4, lcGroup4
	Store NULL To poContracte

	TEXT TO lcSchema4 NOSHOW 
id_ctr N(10), id_part N(12), denumire C(70), data D, numar C(100), id_tip_ctr N(6), inactiv N(3), denumire_tip C(100), tata C(200), valftva N(18,4), valctva N(18,4), id_valuta N(7), nume_val C(20), val_discount N(18,4), proc_tva N(8,2), incetat N(3), data_inceput D, data_sfarsit D, data_incetat D, motiv_incetat C(200), scadenta_incasare N(5), coef_penalitati N(8,2), id_responsabil N(12), id_sectie N(7), sectie C(50), durata N(7), semnat N(3), observatii M, sters N(3), id_util N(10), dataora D, id_utils N(10), dataoras D, opt_facturare N(6), text_standard N(3), id_agent N(20), responsabil C(70), nume_agent C(70), contract C(111), id_nota N(10), descriere C(250), id_selectie N(6), selectie C(100), grnt_proc_ret N(4), grnt_val_ret N(12,4), grnt_alerta1 N(6), grnt_proc_alerta1 N(5), grnt_pv_nr N(12), grnt_pv_data D, numar_intern C(20), data_intern D, ofertanti C(200), tip_istoric C(1), id_tata N(10), activ N(3), grnt_perioada N(4), afisare_scadenta N(3), id_sucursala N(7), tip_curs N(4), tip_curs_explicatie C(100), coef_penalitati2 N(8,2), zile_penalitati N(6), zile_penalitati2 N(6), zile_gratie_penalitati N(6)	
	ENDTEXT 
	TEXT TO lcSelect4 NOSHOW 
Select id_ctr, id_part, denumire, data, numar, id_tip_ctr, inactiv, denumire_tip, tata, valftva, valctva, id_valuta, nume_val, val_discount, proc_tva, incetat, data_inceput, data_sfarsit, data_incetat, motiv_incetat, scadenta_incasare, coef_penalitati, id_responsabil, id_sectie, sectie, durata, semnat, observatii, sters, id_util, dataora, id_utils, dataoras, opt_facturare, text_standard, id_agent, responsabil, nume_agent, contract, id_nota, descriere, id_selectie, selectie, grnt_proc_ret, grnt_val_ret, grnt_alerta1, grnt_proc_alerta1, grnt_pv_nr, grnt_pv_data, numar_intern, data_intern, ofertanti, tip_istoric, id_tata, activ, grnt_perioada, afisare_scadenta, id_sucursala, tip_curs, tip_curs_explicatie, coef_penalitati2, zile_penalitati, zile_penalitati2, zile_gratie_penalitati From vContracte
	ENDTEXT 

	lcFiltru4 = [1=2]
	lcOrder4 = [data desc]
	llAfisare4 = .F.
	lcGroup4 = []
	llModParam4 = .T.
	lcFiltruOriginal4 = []
	gencursor('poContracte', 'crsContracte', lcselect4, lcfiltru4, lcSchema4, lcOrder4, llAfisare4, lcGroup4, llModParam4, lcFiltruOriginal4)
	poContracte.ca_baza1.afisare()

	Private poparteneri
	Store '' To poparteneri

	TEXT TO lcSchema1 NOSHOW 
id_part N(12), denumire C(70), nume C(70), prenume C(70), cod_fiscal C(30), cod_fiscal2 C(30), reg_comert C(30), id_loc_inreg N(12), localitate C(100), tip_persoana N(3), prefix C(30), sufix C(30), banca C(40), cont_banca C(30), inactiv N(3), motiv_inactiv C(100), id_categorie_entitate N(12), categorie_entitate C(150), dataora T, utilizator C(100), adresa C(250), telefon C(50), email C(100), swift_banca C(11), adresa_banca C(150), institutie_publica N(1)
	ENDTEXT 

	Text To lcSelect1 Noshow
SELECT p.id_part, p.denumire, p.nume, p.prenume, p.cod_fiscal, p.cod_fiscal2, p.reg_comert,
	p.id_loc_inreg, p.localitate_inreg, p.tip_persoana, p.prefix, p.sufix, p.banca, p.cont_banca,
	p.inactiv, p.motiv_inactiv,p.id_categorie_entitate,p.categorie_entitate,p.dataora,p.utilizator, 
	p.adresa, p.telefon, p.email, p.swift_banca, p.adresa_banca, p.institutie_publica FROM VNOM_PARTENERI p
	Endtext

	lcOrder1 = [p.denumire]
	lcgroup = []
	lcFiltru1 = [1=2]
	lcFiltruOriginal = []

	* In programul de contracte selectez doar partenerii cu tipul -1 CLIENTI / -2 FURNIZORI
	If Type('gnParametru_prog') <> 'U' And Inlist(gnParametru_prog, 1, 2) && contracte clienti/furnizori
		Text To lcSelect1 ADDITIVE NOSHOW 
	left join CORESP_TIP_PART ctp on ctp.ID_PART = p.ID_PART 
	left join nom_tip_parteneri tp  on (tp.id_tip_part = ctp.id_tip_part and tp.sters = 0) 
		Endtext
		If gnParametru_prog = 1 && contracte clienti
			lcFiltruOriginal = [tp.parent_id = -1]
		Else && gnParametru_prog = 2 && contracte furnizori
			lcFiltruOriginal = [tp.parent_id = -2]
		Endif && gnParametru_prog
	Endif

	llModParam = .T.
	llAfiseaza = .F.

	gencursor('poparteneri', 'crsparteneri', lcSelect1, lcFiltru1, lcSchema1, lcOrder1, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
	poparteneri.ca_baza1.afisare()

	Select crsparteneri
	oParteneri = Createobject('frm_parteneri', lnIdTipPart, lnSpecial, lcMesaj, lcTitlu, lnTipPersoana)
	oParteneri.Show()
	Release poparteneri
	Release pocoresp_tip_parteneri
	Release poAdrese
	Release poContracte
	= close_cctipuri()
	USE IN (SELECT('crsContracte'))
	USE IN (SELECT('crsparteneri'))
	USE IN (SELECT('crsPers_contact'))
	USE IN (SELECT('crsCoduri'))
	USE IN (SELECT('crscoresp_tip_parteneri'))
	USE IN (SELECT('crsAdrese'))
Endproc && viz_parteneri
*************************************************************
******************************************* INCEPUT:vizualizare_partener *******************************************
Procedure vizualizare_partener
	Lparameters tnIdTipPart, tcTitlu, tnTipPersoana
	*!*	tnTipPersoana : tipul de persoana cu care intra implicit la adaugare ( 1 - juridica, 2 - fizica )

	Private poparteneri, poAdrese
	Local lcSchema, lcSelect, lcOrder, lcFiltru, llAfiseaza
	Store '' To poparteneri, poAdrese, poCoduri
	lcSchema = []
	lcSelect = [SELECT distinct p.id_part, p.denumire, p.nume, p.prenume, p.cod_fiscal, p.reg_comert,] + ;
		[p.id_loc_inreg, p.localitate_inreg, p.tip_persoana, p.prefix, p.sufix, p.banca, p.cont_banca,] + ;
		[p.inactiv, p.motiv_inactiv, p.id_categorie_entitate, p.categorie_entitate, p.swift_banca, p.adresa_banca from vnom_parteneri p ] + ;
		[left join coresp_tip_part ctp on ctp.id_part = p.id_part where 1=2]
	lcOrder = [p.denumire]
	lcFiltru = [1=2]
	llAfiseaza = .F.
	gencursor('poparteneri', 'crsparteneri', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza)
	poparteneri.ca_baza1.afisare()

	lcSchema = []
	lcSelect = ['SELECT id_adresa, id_part, denumire_adresa, da_apare, strada, numar,  bloc, scara, etaj, apart, sector,'+] + ;
		['id_loc, localitate, id_regiune, id_judet, judet, codpostal, id_tara, tara, telefon1, telefon2, fax, email, web, '+] + ;
		['inactiv, principala  FROM ] + gcS + [.vadrese_parteneri where 1=2']
	lcFiltru = [1=2]
	lcOrder = [strada]
	llAfiseaza = .F.
	gencursor('poAdrese', 'crsAdrese', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza)
	poAdrese.ca_baza1.afisare()

	lcSchema = []
	lcSelect = ['SELECT id,id_part, cod FROM ] + gcS + [.vparteneri_coduri where 1=2']
	lcFiltru = [1=2]
	lcOrder = [cod]
	llAfiseaza = .F.
	gencursor('poCoduri', 'crsCoduri', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza)
	poCoduri.ca_baza1.afisare()
	Select crsparteneri
	ofrmpartener = Createobject('frm_partener', tnIdTipPart, tcTitlu, tnTipPersoana)
	ofrmpartener.Show(1)
	Release ofrmpartener, poAdrese, poparteneri, poCoduri

Endproc
******************************************* SFARSIT: vizualizare_partener*******************************************
******************************************* INCEPUT: vizualizare_furnizori *******************************************
Procedure vizualizare_furnizori
	Local lnIdTipFurnizor
	If Used('crsconttemp')
		Use In crsconttemp
	Endif
	lcSql = [select id_tip_part from ] + gcS + [.coresp_tip_cont where cont='401']
	lcCursor = [crsconttemp]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	goExecutor.oReset()
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		Return
	Endif
	If Reccount('crsconttemp') > 0
		Select crsconttemp
		lnIdTipFurnizor = id_tip_part
		Use In crsconttemp
		
		DO viz_parteneri with lnIdTipFurnizor , 1, "Alegeti tipul", "Furnizori"
*!*				Do vizualizare_partener With lnIdTipFurnizor, "Furnizori"
			
	Else
		Use In crsconttemp
		AMESSAGEBOX("Nu au fost gasite configurarile de tipuri de parteneri pentru contul 401 !", 0 + 48, "Atentie")
	Endif
Endproc
******************************************* SFARSIT: vizualizare_furnizori *******************************************
******************************************* INCEPUT: vizualizare_clienti *******************************************
Procedure vizualizare_clienti
	LPARAMETERS tlVizualizareParteneri
	* tlVizualizareParteneri: .F. frm_partener, .T. frm_parteneri
	If Used('crsconttemp')
		Use In crsconttemp
	ENDIF

	lcSql = [select id_tip_part from ] + gcS + [.coresp_tip_cont where cont='] + gcCont411 + [']
	lcCursor = [crsconttemp]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	goExecutor.oReset()
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		Return
	Endif
	If Reccount('crsconttemp') > 0
		Select crsconttemp
		lnIdTipClient = id_tip_part
		Use In crsconttemp

*!*			IF m.tlVizualizareParteneri
			DO viz_parteneri with lnIdTipClient, 1, "Alegeti tipul", "Clienti"
*!*			ELSE 	
*!*				Do vizualizare_partener With lnIdTipClient, "Clienti"
*!*			ENDIF 	
	Else
		Use In crsconttemp
		AMESSAGEBOX("Nu au fost gasite configurarile de tipuri de parteneri pentru contul " + gcCont411 + " !", 0 + 48, "Atentie")
	Endif
Endproc
******************************************* SFARSIT: vizualizare_clienti *******************************************
******************************************* INCEPUT: vizualizare_responsabili *******************************************
Procedure vizualizare_responsabili
	Do vizualizare_partener With (gnIdTipResponsabili), ("Responsabili"), (2)
Endproc
******************************************* SFARSIT: vizualizare_delegati *******************************************
******************************************* INCEPUT: vizualizare_delegati *******************************************
Procedure vizualizare_delegati
	Do vizualizare_partener With (gnIdTipDelegati), ("Delegati"), (2)
Endproc
******************************************* SFARSIT: vizualizare_delegati *******************************************
******************************************* INCEPUT: vizualizare_agenti *******************************************
Procedure vizualizare_agenti
	Do vizualizare_partener With (gnIdTipAgenti), ("Agenti"), (2)
Endproc
******************************************* SFARSIT: vizualizare_agenti *******************************************
Procedure viz_entitati_conturi

	** load cursor crstipuriconturi gol:

	Private poconturi, pcselect4, pcfiltru4, pcschema4, pcorder4
	Store "" To pcselect4, pcfiltru4, pcschema4, pcorder4, poconturi
	pcselect4 = ['SELECT * FROM ] + gcS + [.CONFIG_CONT_IREG where 1=2']
	pcfiltru4 = [1=2]
	pcschema4 = ['']
	pcorder4 = [CONT]
	llAfisare4 = .F.
	gencursor('poconturi', 'crsconturi', pcselect4, pcfiltru4, pcschema4, pcorder4, llAfisare4)
	poconturi.ca_baza1.afisare()

	Private potipuri_conturi, pcselect3, pcfiltru3, pcschema3, pcorder3
	Store "" To pcselect3, pcfiltru3, pcschema3, pcorder3, potipuri_conturi
	**pcselect2=['SELECT * FROM '+]+gcS+[+'CORESP_TIP_PART join NOM_TIP_PARTENERI on CORESP_TIP_PART.ID_TIP_PART=NOM_TIP_PARTENERI.ID_TIP_PART where 2=2']
	pcselect3 = ['SELECT * FROM ] + gcS + [.VCORESP_TIP_CONT where 1=2']
	pcfiltru3 = [1=2]
	pcschema3 = ['']
	pcorder3 = [CONT]
	llAfisare3 = .F.
	gencursor('potipuri_conturi', 'crstipuriconturi', pcselect3, pcfiltru3, pcschema3, pcorder3, llAfisare3)
	potipuri_conturi.ca_baza1.afisare()

	** load cursor crstipuriparteneri plin:
	Private potipuri_parteneri, pcselect2, pcfiltru2, pcschema2, pcorder2
	Store "" To pcselect2, pcfiltru2, pcschema2, pcorder2, potipuri_parteneri
	**pcselect2=['SELECT * FROM '+]+gcS+[+'CORESP_TIP_PART join NOM_TIP_PARTENERI on CORESP_TIP_PART.ID_TIP_PART=NOM_TIP_PARTENERI.ID_TIP_PART where 2=2']
	pcselect2 = ['SELECT * FROM ] + gcS + [.VNOM_TIP_PARTENERI where 1=2']
	pcfiltru2 = [2=2]
	pcschema2 = ['']
	pcorder2 = [TIP_PARTENER]
	llAfisare2 = .F.
	gencursor('potipuri_parteneri', 'crstipuriparteneri', pcselect2, pcfiltru2, pcschema2, pcorder2, llAfisare2)
	potipuri_parteneri.ca_baza1.afisare()

	Select crstipuriparteneri
	oEntitati_conturi = Createobject('frm_entitati_conturi')
	oEntitati_conturi.Show()
	Release poconturi
	Release potipuri_conturi
	Release potipuri_parteneri

Endproc && viz_entitati_conturi
******************************************* SFARSIT: viz_entitati_conturi *******************************************

*!*	11.04.2012 : marius.atanasiu
Procedure lucrari_validat_nou
	nom_lucrari_nou()
Endproc
*************************************************************
***proceduri lansare forme de insert nou pt. cauta_alfa:*****
*************************************************************
Procedure nom_lucrari_nou
	Local loRec, lnSucces, lcSelect, lcCursor

	lcSelect = [select * from ] + gcS + [.nom_lucrari where 1=2]
	lcCursor = [crsLucrariTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return Null
	Endif

	Select (lcCursor)
	Scatter Name loRec
	AddProperty(loRec, "nume_parinte", "")
	Do Adauga_Modifica_Inregistrare With 'lucrari', loRec, , "INSERT"
	If Used(lcCursor)
		Use In (lcCursor)
	Endif

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif
Endproc
***======================================================================================

*!* 28.07.2006
*!* MARIUS.MUTU
Procedure nom_lucrari_modifica
	Parameters tnIdLucrare

	Local loRec, lnSucces, lcSelect
	loRec = Null

	If Empty(tnIdLucrare) Or Type('tnIdLucrare') # 'N' Or Isnull(tnIdLucrare)
		Return loRec
	Endif


	lcSelect = [select * from ] + gcS + [.nom_lucrari where id_lucrare = ?tnIdLucrare]
	lcCursor = [crsLucrariTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return loRec
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Use In (lcCursor)

	AddProperty(loRec, "nume_parinte", "")

	If !Isnull(loRec.id_tata)
		lcSelect = [select nrord from ] + gcS + [.nom_lucrari where sters = 0 and id_lucrare = ] + Transform(loRec.id_tata)
		lcCursor = [crsLucrariTemp]
		lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Else
			loRec.nume_parinte = Alltrim(crsLucrariTemp.nrord)
		Endif
		If Used(lcCursor)
			Use In (lcCursor)
		Endif
	Endif

	Do Adauga_Modifica_Inregistrare With 'lucrari', loRec, loRec.id_lucrare, "UPDATE"


	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && nom_lucrari_modifica
***======================================================================================

Procedure nom_fdoc_nou

	Private pofdoc, pcschema1, pcselect1
	Store '' To pofdoc
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_fdoc where 1=2']
	pcorder1 = [fel_document]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pofdoc', 'v_fdoc_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pofdoc.ca_baza1.afisare()
	***
	Select v_fdoc_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'fdoc', loRec, , "INSERT"
	Use In v_fdoc_nou

Endproc


Procedure nom_gestiuni_nou
	Lparameters tnIdGestiune
	* tnIdGestiune (optional): daca se doreste crearea unei gestiuni prin copierea unei alte gestiuni (tnIdGestiune)

	Private pogestiuni
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal, llBlank
	Store '' To pogestiuni

	lcSchema = []
	lcSelect = [select * from vnom_gestiuni]
	lcOrder = [nume_gestiune]
	lcFiltru = Iif(!Empty(Nvl(tnIdGestiune, 0)), [id_gestiune = ] + Transform(tnIdGestiune), [1=2])
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []

	gencursor('pogestiuni', 'v_gestiuni_nou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	pogestiuni.ca_baza1.afisare()

	***
	Select v_gestiuni_nou
	If Empty(Nvl(tnIdGestiune, 0))
		Scatter Name loRec Memo Blank
		loRec.id_responsabil = Null	&&	modificare ROAGEST v 2.0.150
		loRec.id_sectie = Null		&&	modificare ROAGEST v 2.1.2
	Else
		Scatter Name loRec Memo
		loRec.id_gestiune = Null
	Endif

	Use In (Select('v_gestiuni_nou'))

	= ccsucursale()
	= cctipuri_gestiuni()
	llBlank = .T.
	= ccsectii(m.llBlank)

	loRec.id_sucursala = gnIdSucursala
	Do Adauga_Modifica_Inregistrare With 'gestiuni', loRec, , "INSERT"

	= close_ccsucursale()
	= close_cctipuri_gestiuni()
	= close_ccsectii()
Endproc


*!* 18.09.2006
*!* MARIUS.MUTU
Procedure nom_gestiuni_modifica
	Parameters tnIdGestiune

	Local loRec, lnSucces, lcSelect, llBlank
	loRec = Null

	If Empty(tnIdGestiune) Or Type('tnIdGestiune') # 'N' Or Isnull(tnIdGestiune)
		Return loRec
	Endif


	lcSelect = [select * from vnom_gestiuni where id_gestiune = ?tnIdGestiune]
	lcCursor = [crsGestiuneTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return loRec
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Use In (lcCursor)

	= ccsucursale()
	= cctipuri_gestiuni()
	llBlank = .T.
	= ccsectii(m.llBlank)

	Select vnom_sucursale
	Locate For id_sucursala = loRec.id_sucursala
	If Found()
		loRec.sucursala = vnom_sucursale.sucursala
	Endif

	Select vtipuri_gestiuni
	Locate For id_tipgest = loRec.nr_pag
	If Found()
		loRec.nume_tip = vtipuri_gestiuni.nume_tip
	Endif

	Do Adauga_Modifica_Inregistrare With 'gestiuni', loRec, loRec.id_gestiune, "UPDATE"

	= close_ccsucursale()
	= close_cctipuri_gestiuni()
	= close_ccsectii()

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && nom_gestiuni_modifica
***======================================================================================


*************************************************************
Procedure nom_judete_nou

	Private pojudete, pcschema1, pcselect1
	Store '' To pojudete
	pcschema1 = ['']
	pcselect1 = ['select * from syn_vnom_judete where 1=2']
	pcorder1 = [judet]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pojudete', 'v_judete_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pojudete.ca_baza1.afisare()
	***
	Select v_judete_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'judet', loRec, , "INSERT"
	Use In v_judete_nou

Endproc
*************************************************************
Procedure nom_responsabili_nou

	Private poresponsabili, pcschema1, pcselect1
	Store '' To poresponsabili
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_responsabili where 1=2']
	pcorder1 = [nume]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poresponsabili', 'v_responsabili_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poresponsabili.ca_baza1.afisare()
	***
	Select v_responsabili_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'responsabili', loRec, , "INSERT"
	Use In v_responsabili_nou

Endproc
*************************************************************
Procedure nom_sectii_nou

	Private posectii, pcschema1, pcselect1
	Store '' To posectii
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_sectii where 1=2']
	pcorder1 = [sectie]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('posectii', 'v_sectii_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	posectii.ca_baza1.afisare()
	***
	Select v_sectii_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'sectii', loRec, , "INSERT"
	Use In v_sectii_nou

Endproc
*************************************************************
Procedure nom_venchel_nou

	Private posectii, pcschema1, pcselect1
	Store '' To povenchel
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_venchel where 1=2']
	pcorder1 = [tip_venchelt]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('povenchel', 'v_venchel_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	povenchel.ca_baza1.afisare()
	***
	Select v_venchel_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'venchel', loRec, , "INSERT"
	Use In v_venchel_nou

Endproc
*************************************************************
Procedure nom_localitati_nou

	Private polocalitati, pcschema1, pcselect1
	Store '' To polocalitati
	pcschema1 = ['']
	pcselect1 = ['select * from syn_vnom_localitati where 1=2']
	pcorder1 = [localitate]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('polocalitati', 'v_localitati_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	polocalitati.ca_baza1.afisare()
	***
	update_judete()
	Select v_localitati_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'localitati', loRec, , "INSERT"
	Use In v_localitati_nou

Endproc
*************************************************************
Procedure nom_plcont_nou

	Private poplcont, pcschema1, pcselect1
	Store '' To poplcont
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_plcont where 1=2']
	pcorder1 = [cont]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poplcont', 'v_plcont_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poplcont.ca_baza1.afisare()
	***

	Select v_plcont_nou
	Scatter Name loRec Blank
	loRec.an = gnan
	Do Adauga_Modifica_Inregistrare With 'plcont', loRec, , "INSERT"
	Use In v_plcont_nou

Endproc

*************************************************************

*************************************************************
Procedure nom_parteneri_nou
	Lparameters tnIdTipPart, tcTipPart, tnSpecial, tnTipPersoana, tnIdPartCoresp, toDate, tnIdPart
	*!*	tnSpecial		=	1	=>	nu poate sa aleaga alt tip decat tnIdTipPart
	*!* tnTipPersoana ( cu ce tip de persoana intra implicit )
	*!*					= 	1	=>	juridica
	*!*					=	2	=>	fizica
	*!* tnIdPartCoresp	=	la adaugarea unui delegat, este id_part al clientului pentru care se adauga delegatul
	*!* todate = contine proprietati completate pentru adaugarea silentioasa fara sa mai arate formularul nom_parteneri_nou
	*!* tnId_Part = se populeaza formularul de adaugare partener cu datele partenerului dat (copiere partener)
	
	* Intoarce obiect cu partenerul creat si Id-ul partenerului completat sau NULL daca eroare
	
	Private poparteneri
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal, lnSpecial, llCopiere, llSilentios
	LOCAL lnIdPartener, lcSelect2, lnTipPersFizica
	lnTipPersFizica = 2
	lcSelect2 = SELECT()
	lnIdPartener = 0
	Store '' To poparteneri
	Private loRec
	Private pnIdPart, pnIdTipPart
	pnIdPart = 0
	pnIdTipPart = 0

	If !Empty(tnSpecial)
		lnSpecial = tnSpecial
	Else
		lnSpecial = 0
	Endif

	If !Empty(tnTipPersoana)
		lnTipPersoana = tnTipPersoana
	Else
		lnTipPersoana = 1
	Endif

	llCopiere = Type('tnIdPart') = 'N'
	pnIdPart = Iif(Empty(m.tnIdPart), 0, m.tnIdPart)

	lcSchema = []
	* lcSelect=[SELECT id_part, denumire, nume, prenume, cod_fiscal, reg_comert, categorie_entitate, id_categorie_entitate, id_loc_inreg, localitate_inreg, tip_persoana, prefix, sufix, banca, cont_banca, inactiv, motiv_inactiv FROM ]+gcS+[.VNOM_PARTENERI]
	lcSelect = [select id_part, denumire, nume, prenume, cod_fiscal, cod_fiscal2, reg_comert, id_loc_inreg, id_categorie_entitate, localitate_inreg, prefix, sufix, ] + ;
		[tip_persoana, banca, cont_banca, motiv_inactiv, inactiv, eliberatde, dataeliberat, email, web, fax, id_adresa, adresa, telefon, telefon2, id_loc, localitate, ] + ;
		[judet, id_judet, sector, apart, etaj, scara, bloc, strada, numar, codpostal, id_tara, tara, categorie_entitate, dataora, utilizator, swift_banca, adresa_banca, institutie_publica from vnom_parteneri]

	lcOrder = [nume]
	If !m.llCopiere
		lcFiltru = [1=2]
	Else
		lcFiltru = [id_part = ] + Alltrim(Str(m.pnIdPart))
	Endif
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []
	gencursor('poparteneri', 'crsParteneriNou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poparteneri.ca_baza1.afisare()
	***

	If Pcount() > 0
		Do Case
			Case Type('tnIdTipPart') = 'N'
				pnIdTipPart = tnIdTipPart
			Case Type('tnIdTipPart') = 'C'
				pnIdTipPart = Round(Val(Getwordnum(tnIdTipPart, 1, ",")), 0)
			Otherwise
				pnIdTipPart = 0
		Endcase
	Endif

	Select crsParteneriNou
	If !m.llCopiere
		Scatter Name loRec Blank
	Else
		Scatter Name loRec
	ENDIF
	loRec.tip_persoana = lnTipPersoana && juridica 
		
	AddProperty(loRec, "id_tip_part", pnIdTipPart)
	AddProperty(loRec, "tip_partener", "0")
	AddProperty(loRec, "special", lnSpecial)
	*!*	modificare 10.01
	*!*	ccorespdel : poate fi un id (id_part) sau o lista de id-uri (id_part) separate prin virgula,dar fara virgula la final
	AddProperty(loRec, "ccorespdel", Iif(Empty(tnIdPartCoresp), [], Alltrim(Str(tnIdPartCoresp))))
	*!*	^

	IF TYPE('toDate') = 'O'
		IF TYPE('toDate.denumire')= 'C' AND !EMPTY(toDate.denumire)
			loRec.denumire = toDate.denumire
		ENDIF 	
		IF TYPE('toDate.nume')= 'C' AND !EMPTY(toDate.nume)
			loRec.nume = toDate.nume
		ENDIF 	
		IF TYPE('toDate.prenume')= 'C' AND !EMPTY(toDate.prenume)
			loRec.prenume = toDate.prenume
		ENDIF 	
		IF TYPE('toDate.cod_fiscal')= 'C' AND !EMPTY(toDate.cod_fiscal)
			loRec.cod_fiscal = toDate.cod_fiscal
		ENDIF 
		
		IF TYPE('toDate.tip_persoana ')= 'N' AND !EMPTY(toDate.tip_persoana )
			loRec.tip_persoana  = toDate.tip_persoana 
		ENDIF 							
		IF TYPE('toDate.id_tip_part')= 'N' AND !EMPTY(toDate.id_tip_part)
			loRec.id_tip_part = toDate.id_tip_part
		ENDIF 							
	ENDIF 
	
	* Persoana fizica cu denumire, fara nume, completez nume si prenume din denumire
	IF loRec.tip_persoana = m.lnTipPersFizica AND !EMPTY(NVL(loRec.denumire,'')) AND EMPTY(NVL(loRec.nume,''))
		lnPos = AT(' ', loRec.denumire)
		IF m.lnPos > 0
			loRec.nume = LEFT(loRec.denumire, m.lnPos)
			loRec.prenume = SUBSTR(loRec.denumire, m.lnPos + 1)
		ENDIF 	
	ENDIF 

	* Nu apare formularul daca toDate.lSilentios = .T. sau exista toDate
	llSilentios = .F.
	IF TYPE('toDate.lSilentios') = 'L' 
		llSilentios = toDate.lSilentios
	ELSE 
		llSilentios =  (TYPE('toDate') = 'O')
	ENDIF 
	

	*!*		=cclocalitati()
	= cccateg_ent()

	If Type('gnParametru_prog') <> 'U'
		Do Case
			Case gnParametru_prog = 1 && contracte clienti
				pnParent_id = -1
			Case gnParametru_prog = 2 && contracte furnizori
				pnParent_id = -2
		Endcase
	Else
		pnParent_id = 0
	Endif

	If !m.llSilentios
		lcSel = [{call pack_def.get_partener_tipuri(?pnIdPart, ?pnIdTipPart, ?pnParent_id)}]
		lcCursor = 'v_nom_tip_parteneri'
		lnSucces = goExecutor.oExecute(lcSel, lcCursor)

		If lnSucces < 0
			AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
			Return
		Endif

		*!*	modificare adrese parteneri 12.2013
		gnButon = 2
		lcSql = [SELECT id_adresa, id_part, denumire_adresa, da_apare, strada, numar,  bloc, scara, etaj, apart, sector,] + ;
			[id_loc, localitate, id_regiune, id_judet, judet, codpostal, id_tara, tara, telefon1, telefon2,] + ;
			[fax, email, web, inactiv, principala,id_adresa as id_adresa_orig FROM vadrese_parteneri where 1=2]
		lcCursor = [crsAdreseEnt]
		If goExecutor.oExecuta(lcSql, lcCursor)
			lcSql = [SELECT id_pers, id_part, nume, prenume, apelativ, functia, telefon, email, inactiv, principal, id_pers as id_pers_orig  FROM vpers_contact where 1=2]
			lcCursor2 = [crsPersContactEnt]
			If goExecutor.oExecuta(lcSql, lcCursor2)
				gnButon = Adauga_Modifica_Inregistrare("parteneri", loRec, @lnIdPartener, "INSERT") && In oproceduri_ams.prg
			Endif
			Use In (Select(lcCursor2))
		Endif
		Use In (Select(lcCursor))

		*!*			Do Adauga_Modifica_Inregistrare With "parteneri",loRec,,"INSERT" In oproceduri_ams.prg
		*!*	modificare adrese parteneri 12.2013	^
		*!*			=close_cclocalitati()
		= close_categ_ent()

		*!*	modificare ROACONT 2.0.40
		= close_cctipuri()
		*!*	modificare ROACONT 2.0.40	^

		SELECT (m.lcSelect2)
		If gnButon = 1
			loRec.id_part = m.pnIdPart
			Return loRec
		Else
			Return Null
		Endif
	Else
		AdaugarePartener = Createobject("cus_odata_parteneri")
		lnIdPartener = 0
		AdaugarePartener.lSilent = .T.
		AdaugarePartener.salvare(toDate, @lnIdPartener)
		toDate.id_part = m.pnIdPart

		*!*	modificare ROACONT 2.0.40
		= close_cctipuri()
		*!*	modificare ROACONT 2.0.40	^

		SELECT (m.lcSelect2)
		If NVL(m.pnIdPart,0) <> 0
			Return toDate
		Else
			Return Null
		Endif
	Endif

Endproc && nom_parteneri_nou

*************************************************************
Procedure nom_parteneri_modifica
	Lparameters tnId_Part, tnIdTipPart, tcTipPart, tnSpecial, tcMesaj
	*!*	tnSpecial	=	1	=>	nu poate sa aleaga alt tip decat tnIdTipPart
	Local lnIdTipPart, lcTipPart, lnSpecial
	If !Empty(tnIdTipPart)
		lnIdTipPart = tnIdTipPart
	Else
		lnIdTipPart = 0
	Endif

	If !Empty(tcTipPart)
		lcTipPart = tcTipPart
	Else
		lcTipPart = []
	Endif

	If !Empty(tnSpecial)
		lnSpecial = tnSpecial
	Else
		lnSpecial = 0
	Endif



	Private poparteneri
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal
	Store '' To poparteneri

	Private pnId_part, pnIdPart
	pnId_part = tnId_Part
	pnIdPart = tnId_Part
	lcSchema = []
	*lcSelect=[SELECT id_part, denumire, nume, prenume, cod_fiscal, reg_comert, id_loc_inreg, categorie_entitate, id_categorie_entitate, localitate_inreg, tip_persoana, prefix, sufix, banca, cont_banca, inactiv, motiv_inactiv FROM VNOM_PARTENERI]
	lcSelect = [select id_part, denumire, nume, prenume, cod_fiscal, cod_fiscal2, reg_comert, id_loc_inreg, id_categorie_entitate, localitate_inreg, prefix, sufix, ] + ;
		[tip_persoana, banca, cont_banca, motiv_inactiv, inactiv, eliberatde, dataeliberat, email, web, fax, id_adresa, adresa, telefon, telefon2, id_loc, localitate, ] + ;
		[judet, id_judet, sector, apart, etaj, scara, bloc, strada, numar, codpostal, id_tara, tara, categorie_entitate, dataora, utilizator, swift_banca, adresa_banca, institutie_publica from vnom_parteneri]
	lcOrder = [nume]
	lcFiltru = []
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = [id_part = ] + Transform(pnId_part)
	gencursor('poparteneri', 'crsParteneriModifica', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poparteneri.ca_baza1.afisare()

	If !Used('crsParteneriModifica')
		Return
	Endif

	Select crsParteneriModifica
	Scatter Name loRec

	AddProperty(loRec, "id_tip_part", lnIdTipPart)
	AddProperty(loRec, "tip_partener", lcTipPart)
	AddProperty(loRec, "special", lnSpecial)
	AddProperty(loRec, "ccorespdel", [])
	pccod_fiscal = loRec.cod_fiscal
	pccontinua = .F.
	*!*		=cclocalitati()
	= cccateg_ent()

	If Type('gnParametru_prog') <> 'U'
		Do Case
			Case gnParametru_prog = 1 && contracte clienti
				pnParent_id = -1
			Case gnParametru_prog = 2 && contracte furnizori
				pnParent_id = -2
			Otherwise
				pnParent_id = 0
		Endcase
	Else
		pnParent_id = 0
	Endif

	lcSel = [{call pack_def.get_partener_tipuri(?pnId_Part, ?loRec.id_tip_part, ?pnParent_id)}]
	lcCursor = 'v_nom_tip_parteneri'
	lnSucces = goExecutor.oExecute(lcSel, lcCursor)

	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
		Return
	Endif

	= cctipuri_selectate(loRec.id_part)
	****inceput exceptii***
*!*		If Reccount('v_nom_tip_parteneri_selectati') > 1
*!*			If lnIdTipPart <> 0 And lnSpecial <> 0 And !Empty(tcMesaj)
*!*				AMESSAGEBOX(tcMesaj, 16, 'Atentie!')
*!*				*!*	modificare ROACONT 2.0.40
*!*				= close_cctipuri()
*!*				= close_cctipuri_selectate()
*!*				*!*	modificare ROACONT 2.0.40	^
*!*				Return Null
*!*			Endif
*!*		Endif
	If gnId_prg_owner = 69
		If Reccount('v_nom_tip_parteneri_selectati') = 1 And v_nom_tip_parteneri_selectati.id_tip_part <> lnIdTipPart
			AMESSAGEBOX(tcMesaj, 16, 'Atentie!')
			*!*	modificare ROACONT 2.0.40
			= close_cctipuri()
			= close_cctipuri_selectate()
			*!*	modificare ROACONT 2.0.40	^
			Return Null
		Endif
	Endif
	****sfarsit exceptii***

	*!*	modificare adrese parteneri 12.2013
	gnButon = 2
	lcSql = [SELECT id_adresa, id_part, denumire_adresa, da_apare, strada, numar,  bloc, scara, etaj, apart, sector,] + ;
		[id_loc, localitate, id_regiune, id_judet, judet, codpostal, id_tara, tara, telefon1, telefon2,] + ;
		[fax, email, web, inactiv, principala, id_adresa as id_adresa_orig FROM vadrese_parteneri where id_part = ?pnId_part]
	lcCursor = [crsAdreseEnt]
	If goExecutor.oExecuta(lcSql, lcCursor)
		lcSql = [SELECT id_pers, id_part, nume, prenume, apelativ, functia, telefon, email, inactiv, principal, id_pers as id_pers_orig ] + ;
			[FROM vpers_contact where id_part = ?pnId_part]
		lcCursor2 = [crsPersContactEnt]
		If goExecutor.oExecuta(lcSql, lcCursor2)
			*!*					PRIVATE poRec
			*!*					poRec = CloneObj(loRec)
			*DO FORM frm_parteneri_nou NAME loAdMod WITH poRec,poRec.id_part,"UPDATE"
			Do Adauga_Modifica_Inregistrare With "parteneri", loRec, loRec.id_part, "UPDATE" In oproceduri_ams.prg
		Endif
		Use In (Select(lcCursor2))
	Endif
	Use In (Select(lcCursor))
	*!*		Do Adauga_Modifica_Inregistrare With "parteneri",loRec,loRec.id_part,"UPDATE" In oproceduri_ams.prg
	*!*	modificare adrese parteneri 12.2013	^
	*!*		=close_cclocalitati()
	= close_cctipuri()
	= close_cctipuri_selectate()
	= close_categ_ent()

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && nom_parteneri_modifica
**************************************************************************************************************************

**************************************************************************************************************************
* local lnId
* lnId = 0
* llSucces = nom_articole_nou(@lnId)
**************************************************************************************************************************
Procedure nom_articole_nou
	LPARAMETERS tnId, toDate
	* tnId: OUT id articol creat
	* toDate: (optional) obiect cu date initiale (ex: denumire, um). are aceleasi atribute ca vnom_articole
	
	LOCAL llSucces, lnButon, loRec
	tnId = 0
	llSucces = goExecutor.oExecuta('select * from vnom_articole where 1=2', 'vnom_articole_nou')
	IF m.llSucces
		Select vnom_articole_nou
		Scatter Name loRec Blank Memo
		
		llSucces = goExecutor.oExecuta('SELECT id, id_part, partener, id_articol, articol, cod FROM VPARTENERI_ARTICOLE_CODURI WHERE 1=2', 'crsParteneriArticoleCoduri')
		
		* Initializez articolul cu date optionale
		IF TYPE('toDate') = 'O'
			CopyObjectProperties(toDate, loRec)

			* cod client
			IF TYPE('toDate.id_client') = 'N' AND TYPE('toDate.client') = 'C' AND TYPE('toDate.cod_client') = 'C' AND !EMPTY(NVL(toDate.id_client, 0)) AND !EMPTY(NVL(toDate.cod_client, ''))
				REPLACE id_part WITH toDate.id_client, partener WITH Alltrim(toDate.client), cod WITH ALLTRIM(toDate.cod_client)
			ENDIF 	

			* cod furnizor
			IF TYPE('toDate.id_furnizor') = 'N' AND TYPE('toDate.furnizor') = 'C' AND TYPE('toDate.cod_furnizor') = 'C' AND !EMPTY(NVL(toDate.id_furnizor, 0)) AND !EMPTY(NVL(toDate.cod_furnizor, ''))
				loRec.id_part = toDate.id_furnizor
				loRec.partener = toDate.furnizor
				loRec.codmatf = ALLTRIM(toDate.cod_furnizor)
			ENDIF 	
			
		ENDIF 	
	ENDIF 
	* actualizez vnom_um de fiecare data, poate am facut modificari in asocierea um/cod_um_iso
	IF m.llSucces
		llSucces = update_um()
	ENDIF 	
	IF m.llSucces
		IF !USED('vnom_um_iso')
			llSucces = update_um_iso()
		ENDIF 
	ENDIF 
	IF m.llSucces	
		DO CASE 
			CASE Type('gcNumeProgram') = 'C' And Inlist(Alltrim(Upper(gcNumeProgram)), 'ROAPRETURI', 'ROACONTRACTE')
				loRec.in_crm = 1
			CASE Type('gcNumeProgram') = 'C' And Inlist(Alltrim(Upper(gcNumeProgram)), 'ROAACNPRO')
				loRec.tip = 1 && manopera
				loRec.in_crm = 0
				loRec.in_stoc = 0
			OTHERWISE 				
				loRec.in_stoc = 1
		ENDCASE 

		If m.gnCodMatAutomat = 2
			Private poGeneratorCodmat

			poGeneratorCodmat= Createobject("oGeneratorNumere")
			lnRezultat = poGeneratorCodmat.creeaza_cursor_serii(14)
		EndIf 
		If m.gnCodBareAutomat = 2
			Private poGeneratorCodBare
			poGeneratorCodBare= Createobject("oGeneratorNumere")
			lnRezultat2 = poGeneratorCodBare.creeaza_cursor_serii(15)
		EndIf 
		
		lnButon = Adauga_Modifica_Inregistrare('catalog_articole', loRec, @tnId , "INSERT")
		llSucces = (m.lnButon = 1)
	ENDIF 	
	Use In (SELECT('vnom_articole_nou'))
	USE IN (SELECT('crsParteneriArticoleCoduri'))
	RETURN m.llSucces
Endproc
**************************************************************************************************************************
**************************************************************************************************************************
Procedure nom_articole2_nou
	LOCAL llSucces, lnButon, loRec
	* in contracte

	llSucces = goExecutor.oExecuta('select * from vnom_articole where 1=2', 'vnom_articole_nou')
	IF m.llSucces
		Select vnom_articole_nou
		Scatter Name loRec Blank Memo
		llSucces = goExecutor.oExecuta('SELECT id, id_part, partener, id_articol, articol, cod FROM VPARTENERI_ARTICOLE_CODURI WHERE 1=2', 'crsParteneriArticoleCoduri')
	ENDIF 
	* actualizez vnom_um de fiecare data, poate am facut modificari in asocierea um/cod_um_iso
	IF m.llSucces
		llSucces = update_um()
	ENDIF 
	IF m.llSucces
		IF !USED('vnom_um_iso')
			llSucces = update_um_iso()
		ENDIF 
	ENDIF 	
	IF m.llSucces	
		lnButon = Adauga_Modifica_Inregistrare('catalog_articole2', loRec, , "INSERT")
		llSucces = (m.lnButon = 1)
	ENDIF 	
	Use In (SELECT('vnom_articole_nou'))
	USE IN (SELECT('crsParteneriArticoleCoduri'))	
	RETURN m.llSucces
Endproc
**************************************************************************************************************************

**************************************************************************************************************************
* llSucces = nom_articole_modifica(lnId)
**************************************************************************************************************************
Procedure nom_articole_modifica
	LPARAMETERS tnId

	LOCAL llSucces, lnButon, loRec, lnId
	lnId = tnId
	llSucces = goExecutor.oExecuta('select * from vnom_articole where id_articol = ' + ALLTRIM(STR(m.lnId)), 'vnom_articole_nou')
	IF m.llSucces
		Select vnom_articole_nou
		Scatter Name loRec Memo
		llSucces = goExecutor.oExecuta('SELECT id, id_part, partener, id_articol, articol, cod FROM VPARTENERI_ARTICOLE_CODURI WHERE id_articol = ' + ALLTRIM(STR(m.lnId)) + ' order by partener', 'crsParteneriArticoleCoduri')
	ENDIF 
	* actualizez vnom_um de fiecare data, poate am facut modificari in asocierea um/cod_um_iso
	IF m.llSucces
		llSucces = update_um()
	ENDIF 
	IF m.llSucces
		IF !USED('vnom_um_iso')
			llSucces = update_um_iso()
		ENDIF 
	ENDIF 	
	IF m.llSucces	
		lorec.conditii_pastrare = Nvl(lorec.conditii_pastrare,'')

		If gnCodMatAutomat = 2
			Private poGeneratorCodmat

			poGeneratorCodmat= Createobject("oGeneratorNumere")
			lnRezultat = poGeneratorCodmat.creeaza_cursor_serii(14)
		Endif
		If gnCodBareAutomat = 2
			Private poGeneratorCodBare
			poGeneratorCodBare= Createobject("oGeneratorNumere")
			lnRezultat2 = poGeneratorCodBare.creeaza_cursor_serii(15)
		Endif

		lnButon = Adauga_Modifica_Inregistrare('catalog_articole', lorec, lnId, 'UPDATE')
		llSucces = (m.lnButon = 1)
	ENDIF 	
	Use In (SELECT('vnom_articole_nou'))
	USE IN (SELECT('crsParteneriArticoleCoduri'))	
	RETURN m.llSucces
Endproc
**************************************************************************************************************************

Procedure viz_valute(  )

	Private povalute, pcschema1, pcselect1
	Store '' To povalute
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_valute where 1=2']
	pcorder1 = [nume_val]
	pcfiltru1 = [inactiv=0]
	llAfiseaza = .F.
	gencursor('povalute', 'v_valute', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	povalute.ca_baza1.afisare()
	ofrmval = Createobject('frm_valute')
	ofrmval.Show(1)
	Release povalute

Endproc
**************************************************************************************************************************
Procedure nom_valute_nou


	Private povalute, pcschema1, pcselect1
	Store '' To povalute
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_valute where 1=2']
	pcorder1 = [ nume_val ]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('povalute', 'valute_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	povalute.ca_baza1.afisare()
	***

	Select valute_nou
	Scatter Name loRec Blank

	Do Adauga_Modifica_Inregistrare With 'valute', loRec, , "INSERT"
	Use In valute_nou

Endproc


**************************************************************************************************************************
Procedure  sal_nom_mes_nou
	*!*	modificare	11.01.2012
	AddProperty(poRec, "tip_modificare", 1)
	AddProperty(poRec, "dataconsemnare", {})
	*!*	modificare	11.01.2012	^
	Do Adauga_Modifica_Inregistrare With "meserii", poRec, , "INSERT", , "addmes"
Endproc
**************************************************************************************************************************
Procedure sal_nom_formatii_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	If Used('v_sectie')
		Use In v_sectie
	Endif
	*cursor sectie    v_sectie
	lcSql = [select * from ] + gcS + [.vnom_sectii order by sectie]&& where inactiv = 0]
	lcCursor = [v_sectie]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Endif
	Select v_sectie
	Scatter Name loRec Additive
	*cursor semnaturi    v_semnaturi
	If Used('v_semnaturi')
		Use In v_semnaturi
	Endif	
	lcSql = [select * from ] + gcS + [.sal_semnaturi where sters = 0 and inactiv = 0 order by denumire ]&& where inactiv = 0]
	lcCursor = [v_semnaturi]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Endif
	Select v_semnaturi
	Scatter Name loRec Additive
	*cursor transa    v_transe
	If Used('v_transe')
		Use In v_transe
	Endif
	lcSql = [select * from ] + gcS + [.SAL_vNOM_TRANSE where inactiv = 0 and sters = 0]
	lcCursor = [v_transe]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Endif
	Select v_transe
	Scatter Name loRec Additive

	Do Adauga_Modifica_Inregistrare With "FORMATII", loRec, , "INSERT", , "addform"
Endproc
**************************************************************************************************************************
Procedure sal_nom_tipctr_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	*cursor ore/zi   v_nomore
	If Used('v_nomore')
		Use In v_nomore
	Endif

	lcSql = [select * from ] + gcS + [.SAL_vNOMORE where inactiv = 0 and sters = 0]
	lcCursor = [v_nomore]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Endif
	Select v_nomore
	Scatter Name loRec Additive

	Do Adauga_Modifica_Inregistrare With "tipctr", loRec, , "INSERT", , "addtip"
Endproc
**************************************************************************************************************************
Procedure sal_nom_handicap_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	Do Adauga_Modifica_Inregistrare With "grdhand", loRec, , "INSERT", , "addhand"
Endproc
**************************************************************************************************************************
Procedure sal_nom_grmun_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	Do Adauga_Modifica_Inregistrare With "grpmun", loRec, , "INSERT", , "addgrp"
Endproc
**************************************************************************************************************************
Procedure sal_caseasig_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	*cursor judete   v_jud
	If Used('v_jud')
		Use In v_jud
	Endif
	lcSql = [SELECT * from syn_vnom_judete where inactiv = 0]
	lcCursor = [v_jud]
	lnSucces = goExecutor.oExecute(lcSql, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, "Eroare")
	Endif
	Select v_jud
	Scatter Name loRec Additive

	Do Adauga_Modifica_Inregistrare With "caseasig", loRec, , "INSERT", , "addcasa"
Endproc
**************************************************************************************************************************
Procedure sal_nom_cm_nou
	Local loRec
	Store '' To loRec
	loRec = poRec
	lcSelect = [select * from ] + gcS + [.sal_vnom_cm where sters = 0]
	lcCursor = [v_nomtipcm]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare)
		Return
	Endif
	Select v_nomtipcm
	Scatter Name loRec Blank
	*!*	DEBUG
	*!*	SUSPEND
	Do Adauga_Modifica_Inregistrare With "nomcm", loRec, , "INSERT", , "addcm"
Endproc

**************************************************************************************************************************
Procedure adrese_parteneri_nou
	Lparameters tnIdPartener, tcActiune, tcCursor
	*!*	modificare adrese parteneri 12.2013 : am adaugat tcActiune, tcCursor, lcActiune
	Local lcSelect, lcCursor, lnSucces, loRec, lnidpartener, lnPrincipala, lcActiune
	Private pnIdAdresa
	pnIdAdresa = 0

	If Pcount() = 0 Or Type('tnIdPartener') # 'N'
		lnidpartener = 0
	Else
		lnidpartener = tnIdPartener
	Endif
	*!*	modificare adrese parteneri 12.2013
	gnButon = 1
	lcActiune = Evl(tcActiune, "INSERT")
	lcCursor = "crsAdreseTemp"
	If lcActiune = "LOCAL"
		Select * From (tcCursor) With (Buffering = .T.) Where principala = 1 And !Deleted() Into Cursor (lcCursor)
	Else
		lcSelect = "SELECT * FROM vadrese_parteneri where principala = 1 and id_part = " + Transform(lnidpartener)
		If !goExecutor.oExecuta(lcSelect, lcCursor)
			gnButon = 2
		Endif
	Endif
	If gnButon = 1
		If Reccount(lcCursor) = 0
			lnPrincipala = 1
		Else
			lnPrincipala = 0
		Endif
		Select (lcCursor)
		Scatter Name loRec Blank
		Use In (lcCursor)

		loRec.id_part = tnIdPartener
		loRec.principala = lnPrincipala

		Do Adauga_Modifica_Inregistrare With "parteneri_adrese", loRec, , lcActiune In oproceduri_ams.prg
	Endif
	*!*			lcSelect = "SELECT * FROM vadrese_parteneri where principala = 1 and id_part = " + Transform(lnidpartener)
	*!*			lcCursor = "crsAdreseTemp"
	*!*		If goExecutor.oExecuta(lcSelect, lcCursor)
	*!*			If Reccount('crsAdreseTemp') = 0
	*!*				lnPrincipala = 1
	*!*			Else
	*!*				lnPrincipala = 0
	*!*			Endif
	*!*			Select crsAdreseTemp
	*!*			Scatter Name loRec Blank
	*!*			Use In crsAdreseTemp
	*!*			loRec.id_part = tnIdPartener
	*!*			loRec.principala = lnPrincipala
	*!*			Do Adauga_Modifica_Inregistrare With "parteneri_adrese",loRec,,"INSERT" In oproceduri_ams.prg
	*!*		Else
	*!*			gnButon = 2
	*!*		Endif
	*!*	modificare adrese parteneri 12.2013	^

	If gnButon = 1
		loRec.id_adresa = pnIdAdresa
		Return loRec
	Else
		Return Null
	Endif

Endproc && adrese_parteneri_nou

**************************************************************************************************************************
Procedure coduri_parteneri_nou
	Lparameters tnIdPartener

	Local lcSelect, lcCursor, lnSucces, loRec, lnidpartener, lnPrincipala
	Private pnIdAdresa
	pnIdAdresa = 0

	If Pcount() = 0 Or Type('tnIdPartener') # 'N'
		lnidpartener = 0
	Else
		lnidpartener = tnIdPartener
	Endif
	lcSelect = "SELECT * FROM parteneri_coduri where id_part = " + Transform(lnidpartener)
	lcCursor = "crsCoduriTemp"
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare)
		Return
	Endif

	Select crsCoduriTemp
	Scatter Name loRec Blank
	Use In crsCoduriTemp

	loRec.id_part = tnIdPartener

	Do Adauga_Modifica_Inregistrare With "coduri", loRec, , "INSERT" In oproceduri_ams.prg

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && coduri_parteneri_nou
**************************************************************************************************************************
Procedure coduri_parteneri_modifica
	Lparameters tnIdCod

	Local lcSelect, lcCursor, lnSucces, loRec

	lcSelect = "SELECT * FROM parteneri_coduri where id = " + Transform(tnIdCod)
	lcCursor = "crsCoduriTemp"
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare)
		Return
	Endif
	Select crsCoduriTemp
	Scatter Name loRec
	Use In crsCoduriTemp

	Do Adauga_Modifica_Inregistrare With "coduri", loRec, tnIdCod, "UPDATE" In oproceduri_ams.prg

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && coduri_parteneri_modifica
*************************************************************
**************************************************************************************************************************
Procedure adrese_parteneri_modifica
	Lparameters tnIdAdresa, tcActiune, tcCursor
	*!*	modificare adrese parteneri 12.2013 : am adaugat tcActiune, tcCursor
	Local lcSelect, lcCursor, lnSucces, loRec, lcActiune

	*!*	modificare adrese parteneri 12.2013
	gnButon = 1
	lcActiune = Evl(tcActiune, "UPDATE")
	lcCursor = Evl(tcCursor, "crsAdreseTemp")
	If lcActiune = [UPDATE]
		lcSelect = "SELECT * FROM vadrese_parteneri where id_adresa = " + Transform(tnIdAdresa)
		If !goExecutor.oExecuta(lcSelect, lcCursor)
			gnButon = 2
		Endif
	Endif

	If gnButon = 1
		Select (lcCursor)
		Scatter Name loRec
		Do Adauga_Modifica_Inregistrare With "parteneri_adrese", loRec, tnIdAdresa, lcActiune In oproceduri_ams.prg
		If lcActiune = [UPDATE]
			Use In (Select(lcCursor))
		Endif
	Endif
	*!*		lcSelect = "SELECT * FROM vadrese_parteneri where id_adresa = " + Transform(tnIdAdresa)
	*!*		lcCursor = "crsAdreseTemp"
	*!*		lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	*!*		If lnSucces < 0
	*!*			amessagebox(goExecutor.cEroare)
	*!*			Return
	*!*		Endif
	*!*		Select crsAdreseTemp
	*!*		Scatter Name loRec
	*!*		Use In crsAdreseTemp
	*!*		=cclocalitati()
	*!*		=ccJudete()
	*!*		=ccTari()
	*!*		Do Adauga_Modifica_Inregistrare With "parteneri_adrese",loRec,tnIdAdresa,"UPDATE" In oproceduri_ams.prg
	*!*		=close_cclocalitati()
	*!*		=close_ccJudete()
	*!*		=close_ccTari()
	*!*	modificare adrese parteneri 12.2013 ^
	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif
Endproc && adrese_parteneri_modifica
*************************************************************
Procedure contracte_nou
	Parameters tnId_Part, tnIdTip, tnId
	LOCAL lnButon, llSucces, lcSchema, lcSelect, lcOrder, lcFiltru, lcAfiseaza
	
	Private pnId_part, pnId_tip_ctr
	If !Empty(tnId_Part)
		pnId_part = tnId_Part
	Else
		pnId_part = 0
	ENDIF
	
	pnId_tip_ctr = IIF(!EMPTY(m.tnIdTip), m.tnIdTip, 0)

	Private poContracte, pcschema1, pcselect1
	Store '' To poContracte
	lcschema = ['']
	lcselect = ['select * from vcontracte where 1=2']
	lcorder = [denumire,data,numar]
	lcfiltru = [1=2]
	llAfiseaza = .F.
	gencursor('poContracte', 'v_contracte_nou', m.lcSelect, m.lcFiltru, m.lcSchema, m.lcOrder, m.llAfiseaza)
	poContracte.ca_baza1.afisare()
	***
	Select v_contracte_nou
	Scatter Name loRec Blank
	AddProperty(loRec, "numar2", "")
	If Type('loRec.curs') = 'U'
		AddProperty(loRec, "curs", 0)
	Endif
	loRec.tip_istoric = [C]
	loRec.Data = Date()
	loRec.data_inceput = {}
	loRec.data_sfarsit = {}
	loRec.id_part = pnId_part		&&	modificare	11.04.2012
	
	lnButon = Adauga_Modifica_Inregistrare('contract', loRec, @tnId, "INSERT") && In oproceduri_ams.prg
	llSucces = (m.lnButon = 1)	

	Use In v_contracte_nou
	RETURN m.llSucces
Endproc && contracte_nou
*************************************************************
Procedure nom_lucrari_detalii_nou
	Private pniesire, pcNrOrd
	Local loRec, lnSucces, lcSelect
	Store [] To pcNrOrd
	pniesire = 0

	lcSelect = [select * from ] + gcS + [.vlucrari_detalii where 1=2]
	lcCursor = [crsLucrariDetaliiTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return Null
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Use In (lcCursor)
	goExecutor.oFunction2Value([pack_comenzi.genereaza_nr_lucrare], @pcNrOrd)
	loRec.nrord = pcNrOrd
	loRec.data_lucrare = get_ora()
	Do Adauga_Modifica_Inregistrare With 'lucrari_detalii', loRec, , "INSERT"

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif
Endproc
*************************************************************
Procedure nom_masini_nou
	Local loRec, lnSucces, lcSelect

	lcSelect = [select * from ] + gcS + [.vnom_masini where 1=2]
	lcCursor = [crsMasiniTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return Null
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Do Adauga_Modifica_Inregistrare With 'masini', loRec, , "INSERT"
	Use In (lcCursor)

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif
Endproc
*************************************************************
******************************************************************************************************************
Procedure viz_tipuri_ctr

	Private poTipuri_ctr
	Store '' To poTipuri_ctr

	Local lcSchema, lcSelect, lcOrder, lcgroup, lcFiltru, lcFiltruOriginal, llModParam, llAfiseaza

	lcSchema = [id_tip_ctr N(4), denumire_tip C(50), system N(1), id_tata N(4), tip_sup C(200)]
	lcSelect = [select id_tip_ctr, denumire_tip, system, id_tata, TRIM(SUBSTR(tata,1,INSTR(tata,CHR(92),1,nivel)-1)) as tip_sup from vtipuri_contracte ]
	lcOrder = [denumire_tip]
	lcgroup = []
	lcFiltru = [1=2]
	Do Case
		Case gnParametru_prog = 1
			lcFiltruOriginal = [substr(tata,2,6)='CLIENT']
		Case  gnParametru_prog = 2
			lcFiltruOriginal = [substr(tata,2,6)='FURNIZ']
	Endcase

	llModParam = .T.
	llAfiseaza = .F.

	gencursor('poTipuri_ctr', 'cTipuri_ctr', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
	poTipuri_ctr.ca_baza1.afisare()

	Select cTipuri_ctr
	ofrm_t_ctr = Createobject('frm_tipuri_ctr')
	ofrm_t_ctr.Show(1)
	Release poTipuri_ctr

Endproc && viz_tipuri_ctr
******************************************************************************************************************


Procedure nom_calculatoare_nou

	Private poCalculatoare
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal
	Store '' To poCalculatoare

	lcSchema = []
	lcSelect = [select * from vcalculatoare]
	lcOrder = [sucursala, denumire]
	lcFiltru = []
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []

	gencursor('poCalculatoare', 'crsCalcNou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poCalculatoare.ca_baza1.afisare()

	***
	Select crsCalcNou
	Scatter Name loRec Blank
	Use In crsCalcNou

	= ccsucursale()

	Do Adauga_Modifica_Inregistrare With 'calc', loRec, , "INSERT"

	= close_ccsucursale()
Endproc


*!* 18.09.2006
*!* MARIUS.MUTU
Procedure nom_calculatoare_modifica
	Parameters tnIdCalculator

	Local loRec, lnSucces, lcSelect
	loRec = Null

	If Empty(tnIdCalculator) Or Type('tnIdCalculator') # 'N' Or Isnull(tnIdCalculator)
		Return loRec
	Endif


	lcSelect = [select * from vcalculatoare where id_calc = ?tnIdCalculator]
	lcCursor = [crsCalculatoareTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return loRec
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Use In (lcCursor)

	= ccsucursale()

	Select vnom_sucursale
	Locate For id_sucursala = loRec.id_sucursala
	If Found()
		loRec.sucursala = vnom_sucursale.sucursala
	Endif

	Do Adauga_Modifica_Inregistrare With 'calc', loRec, loRec.id_calc, "UPDATE"

	= close_ccsucursale()

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && nom_calculatoare_modifica
***======================================================================================

***======================================================================================
Procedure utilizatorintern_nou

	Private poUtilizatori
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal
	Store '' To poUtilizatori

	lcSchema = []
	lcSelect = [select * from vutilizatori_rol_intern]
	lcOrder = [sucursala, denumire_grup, utilizator]
	lcFiltru = [1=2]
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []

	gencursor('poUtilizatori', 'crsUtilNou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poUtilizatori.ca_baza1.afisare()

	***
	Select crsUtilNou
	Scatter Name loRec Blank
	Use In crsUtilNou

	= ccsucursale()
	= ccutilizatori()
	= ccgrupuri_utilizatori()

	Do Adauga_Modifica_Inregistrare With 'utilizatori', loRec, , "INSERT"

	= close_ccsucursale()
	= close_ccgrupuri_utilizatori()
	= close_ccutilizatori()

Endproc && utilizatorintern_nou
***======================================================================================

*!* 18.09.2006
*!* MARIUS.MUTU
Procedure utilizatorintern_modifica
	Parameters tnIdUtil

	Local loRec, lnSucces, lcSelect, lcCursor
	loRec = Null

	If Empty(tnIdUtil) Or Type('tnIdUtil') # 'N' Or Isnull(tnIdUtil)
		Return loRec
	Endif


	lcSelect = [select * from vutilizatori_rol_intern where id_util = ?tnIdUtil]
	lcCursor = [crsUtilizatoriTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return loRec
	Endif

	Select (lcCursor)
	Scatter Name loRec
	Use In (lcCursor)

	= ccsucursale()
	= ccutilizatori()
	= ccgrupuri_utilizatori()

	Select vnom_sucursale
	Locate For id_sucursala = loRec.id_sucursala
	If Found()
		loRec.sucursala = vnom_sucursale.sucursala
	Endif

	Select vutilizatori
	Locate For id_util = loRec.id_util
	If Found()
		loRec.utilizator = vutilizatori.utilizator
	Endif

	Select vgrupuri_utilizatori
	Locate For id_grup = loRec.id_grup
	If Found()
		loRec.denumire_grup = vgrupuri_utilizatori.denumire_grup
	Endif

	Do Adauga_Modifica_Inregistrare With 'utilizatori', loRec, loRec.id_util, "UPDATE"

	= close_ccsucursale()
	= close_ccgrupuri_utilizatori()
	= close_ccutilizatori()

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && utilizatorintern_modifica
***======================================================================================

Procedure sal_modlic_nou

	Private pomodlic, pcschema1, pcselect1
	Store '' To pomodlic
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.sal_nom_modlic where 1=2']
	pcorder1 = [modlic]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pomodlic', 'v_modlic_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pomodlic.ca_baza1.afisare()
	***
	Select v_modlic_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'modlic', loRec, , "INSERT"
	Use In v_modlic_nou

Endproc
*************************************************************


* PROCEDURE viz_plafon_casa( Tcs )
* Date : 04/04/06, 11:22:25
* author : georgiana.voicu
* description:

****** PARAMETER BLOCK **************
* Parameters : 1
* Parameter 1:
*
******************************************* INCEPUT: viz_plafon_casa *******************************************
Procedure viz_plafon_casa(tcS, tnAn, tnLuna)

	Local lnSucces, lcS
	If Empty(tcS)
		lcS = "CONTAFIN_ORACLE"
	Else
		lcS = tcS
	Endif
	lnAn = Iif(Empty(tnAn), gnan, tnAn)
	lnLuna = Iif(Empty(tnLuna), gnLuna, tnLuna)

	Private pcot, pcschema1, pcselect1
	Store '' To pcot
	pcschema1 = ['']
	pcselect1 = ['select id_calendar, luna, anul, plafon_casa, plafon_plati, plafon_furnizori from ] + lcS + [.calendar where 1=2']
	pcfiltru1 = [ anul = ?lnAn and luna = ?lnluna]
	pcorder1 = [anul, luna]
	gencursor('pcot', 'v_plafon', pcselect1, pcfiltru1, pcschema1, pcorder1)
	pcot.ca_baza1.afisare()
	ofrmpc = Createobject('frm_plafon_casa')
	ofrmpc.ogencursor = pcot
	ofrmpc.ctabel = 'v_plafon'
	ofrmpc.Show(1)
	Release ofrmpc
	If Used('v_plafon')
		Use In v_plafon
	Endif

Endproc
******************************************* SFARSIT: viz_plafon_casa *******************************************
*************************************************************
Procedure nom_sallucrari_nou
	Local loRec, lnSucces, lcSelect, lcCursor

	lcSelect = [select * from ] + gcS + [.sal_vnom_lucrari where 1=2]
	lcCursor = [crsLucrariTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return Null
	Endif

	Select (lcCursor)
	Scatter Name loRec
	AddProperty(loRec, "nume_parinte", "")
	Do Adauga_Modifica_Inregistrare With "sal_lucrari", loRec, , "INSERT", , "addcluc"
	If Used(lcCursor)
		Use In (lcCursor)
	Endif

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif
Endproc
***======================================================================================
***======================================================================================

Procedure sal_tipctr_nou

	Private poctr, pcschema1, pcselect1

	Store '' To poctr
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.sal_nom_tipctr where 1=2']
	pcorder1 = [tip_contract]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poctr', 'v_ctr_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poctr.ca_baza1.afisare()
	***

	Do update_ore In update_roadef_sal.prg
	Select v_ctr_nou
	Scatter Name loRec Blank
	AddProperty(loRec, 'ore', '')
	Do Adauga_Modifica_Inregistrare With 'tipctr', loRec, , "INSERT"
	Use In v_ctr_nou
	Use In v_nomore


Endproc
***======================================================================================


*!* 24.10.2006
*!* MARIUS.MUTU
***======================================================================================
Procedure calcsetare_nou

	Private poCalcSetare
	Local lcSchema, lcSelect, lcFiltru, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal
	poCalcSetare = Null

	lcSchema = []
	lcSelect = [select id_calcsetare, id_calc, calculator, setare, explicatia, valoare, valoare_text, tip, tabel, coloane, titlucoloane, idcoloana, resultcoloana, titlu from vcalc_setari]
	lcOrder = []
	lcFiltru = [1=2]
	llAfiseaza = .F.
	lcgroup = ""
	llModParam = .T.
	lcFiltruOriginal = []

	gencursor('poCalcSetare', 'crsCalcSetareNou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poCalcSetare.ca_baza1.afisare()

	***
	Select crsCalcSetareNou
	Scatter Name loRec Memo Blank
	Use In crsCalcSetareNou

	= cccalculatoare()
	= ccsetari()

	Do Adauga_Modifica_Inregistrare With 'calcsetari', loRec, , "INSERT"

	= close_cccalculatoare()
	= close_ccsetari()

Endproc && calcsetare_nou

***======================================================================================
Procedure calcsetare_modifica
	Parameters tnIdCalcSetare

	Local loRec, lnSucces, lcSelect, lcCursor
	loRec = Null

	If Empty(tnIdCalcSetare) Or Type('tnIdCalcSetare') # 'N' Or Isnull(tnIdCalcSetare)
		Return loRec
	Endif

	lcSelect = [select id_calcsetare, id_calc, calculator, setare, explicatia, valoare, valoare_text, tip, tabel, coloane, titlucoloane, idcoloana, resultcoloana, titlu from vcalc_setari where id_calcsetare = ?tnIdCalcSetare]
	lcCursor = [crsCalcSetareTemp]
	lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
	If lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return loRec
	Endif

	Select (lcCursor)
	Scatter Name loRec Memo
	Use In (lcCursor)

	= cccalculatoare()
	= ccsetari()

	Select vcalculatoare
	Locate For id_calc = loRec.id_calc
	If Found()
		loRec.calculator = vcalculatoare.denumire
	Endif

	Select vsetari
	Locate For setare = loRec.setare
	If Found()
		loRec.setare = vsetari.setare
	Endif

	Do Adauga_Modifica_Inregistrare With 'calcsetari', loRec, loRec.id_calcsetare, "UPDATE"

	= close_cccalculatoare()
	= close_ccsetari()

	If gnButon = 1
		Return loRec
	Else
		Return Null
	Endif

Endproc && calcsetare_modifica
***======================================================================================

Procedure nom_medii_transmisie_nou

	Private poMediu_transmisie, pcschema1, pcselect1
	Store '' To poMediu_transmisie
	pcschema1 = ['']
	pcselect1 = ['select * from vnom_medii_transmisie where 1=2']
	pcorder1 = [mediu_transmisie]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('poMediu_transmisie', 'v_mediu_transmisie_nou', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	poMediu_transmisie.ca_baza1.afisare()
	***
	Select v_mediu_transmisie_nou
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'medii_transmisie', loRec, , "INSERT"
	Use In v_mediu_transmisie_nou

Endproc
***======================================================================================
******************************************* INCEPUT:viz_medii_transmisie *******************************************
Procedure viz_medii_transmisie(  )

	Private poMediu_transmisie, pcschema1, pcselect1
	Store '' To poMediu_transmisie
	pcschema1 = []
	pcselect1 = [select id_mediu, mediu_transmisie from vnom_medii_transmisie]
	pcorder1 = [mediu_transmisie]
	pcfiltru1 = []
	llAfiseaza = .F.
	lcgroup = []
	lcFiltruOriginal = []
	llModParam = .T.
	gencursor('poMediu_transmisie', 'v_medii_transmisie', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal)
	poMediu_transmisie.ca_baza1.afisare()
	ofrmMT = Createobject('frm_medii_transmisie')
	ofrmMT.Show(1)
	Release poMediu_transmisie

Endproc
******************************************* SFARSIT: viz_medii_transmisie *******************************************

Procedure viz_marci(  )

	Private pomarca, pcschema1, pcselect1
	Store '' To pomarca
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_marci_masini where 1=2']
	pcorder1 = [marca_masina]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pomarca', 'v_marci', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pomarca.ca_baza1.afisare()
	ofrmmarca = Createobject('frm_marci')
	ofrmmarca.Show(1)
	Release pomarca

Endproc

Procedure viz_modele(  )

	Private pomodel, pcschema1, pcselect1
	Store '' To pomodel
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.vnom_modele_masini where 1=2']
	pcorder1 = [model_masina]
	pcfiltru1 = [2=2]
	llAfiseaza = .F.
	gencursor('pomodel', 'v_modele', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pomodel.ca_baza1.afisare()
	ofrmmodel = Createobject('frm_modele')
	ofrmmodel.Show(1)
	Release pomodel

Endproc

Procedure vizualizare_soferi
	Do vizualizare_partener With gnIdTipSoferi, "Soferi", 2
Endproc





Procedure nom_nomrute_nou

	Private pofdoc, pcschema1, pcselect1
	Store '' To pofdoc
	pcschema1 = ['']
	pcselect1 = ['select * from ] + gcS + [.fact_vnom_rute where 1=2']
	pcorder1 = [ruta]
	pcfiltru1 = [sters = 0 ]
	llAfiseaza = .F.
	gencursor('pofdoc', 'v_rute', pcselect1, pcfiltru1, pcschema1, pcorder1, llAfiseaza)
	pofdoc.ca_baza1.afisare()
	***
	Select v_rute
	Scatter Name loRec Blank
	Do Adauga_Modifica_Inregistrare With 'nomrute', loRec, , "INSERT"
	Use In v_rute

Endproc
*************************************************************
Procedure proiecte_nou
	Parameters tnId_Part

	Local lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcgroup, llModParam, lcFiltruOriginal
	Private poProiecte
	Store '' To poProiecte

	Private pnId_part
	If !Empty(tnId_Part)
		pnId_part = tnId_Part
	Else
		pnId_part = 0
	Endif


	lcSchema = []
	lcSelect = [select * from con_vproiecte]
	lcOrder = [denumire]
	lcFiltru = [1=2]
	llAfisare = .F.
	lcgroup = []
	llModParam = .T.
	lcFiltruOriginal = []
	gencursor('poProiecte', 'v_proiecte_nou', lcSelect, lcFiltru, lcSchema, lcOrder, llAfisare, lcgroup, llModParam, lcFiltruOriginal)
	poProiecte.ca_baza1.afisare()
	***

	Select v_proiecte_nou
	Scatter Name loRec Blank Memo
	loRec.Data_proiect = Date()
	AddProperty(loRec, 'id_responsabil', 0)
	AddProperty(loRec, 'responsabil', '')
	AddProperty(loRec, 'id_modelproiect', 0)
	AddProperty(loRec, 'modelproiect', '')

	Do Adauga_Modifica_Inregistrare With 'proiecte', loRec, , "INSERT" In oproceduri_ams.prg
	Use In v_proiecte_nou

Endproc && proiecte_nou
*************************************************************


*************************************************************
*** se apeleaza din cauta_alfa_form, butonul but_verifica
*************************************************************
Procedure nom_parteneri_verifica
	Lparameters toPartener

	Local loDate As "empty"
	Local lcCodFiscal, lcDenumire, ldDataAct, lnOptiune, lnRaspuns, loPartener
	lcCodFiscal = Alltrim(Transform(toPartener.cod_fiscal))
	lcDenumire = Upper(Alltrim(Transform(toPartener.denumire)))
	ldDataAct = Iif(Type('toPartener.dataact') = 'D', toPartener.dataact, Date())

	lnOptiune = 0
	loPartener = Null
	loDate = Createobject("empty")
	AddProperty(loDate, "denumire", m.lcDenumire)
	AddProperty(loDate, "cod_fiscal", m.lcCodFiscal)
	AddProperty(loDate, "data", m.ldDataAct)
	lnRaspuns = VerificaCodFiscal(loDate, @lnOptiune, @loPartener)
Endproc && nom_parteneri_verifica


*** se apeleaza din cauta_alfa_form, butonul but_verifica
Procedure nom_parteneri_verifica_old
	Lparameters toPartener
	*!*		Lparameters tlValidare && execut doar validarea codului

	Local loVerificare As "verificarecod"
	Local lcCod, lcDenumire, lcEroare, lcText, lcXml, llIsCIF, llPlatitorTva, llValid, llValidare
	Local loPartener
	llValidare = .F.

	loVerificare = Createobject("verificarecod") && validare.prg

	lcCod = Alltrim(Transform(toPartener.cod_fiscal))
	lcDenumire = Upper(Alltrim(Transform(toPartener.denumire)))
	If Empty(m.lcCod)
		Return
	Endif
	llIsCIF = loVerificare.ISCIF(m.lcCod)

	*!* VERIFIC VALIDITATEA CODULUI
	If llIsCIF
		llValid = loVerificare.Validare('CIF', m.lcCod)
	Else
		llValid = loVerificare.Validare('CNP', m.lcCod)
	Endif

	If llValidare && se verifica doar validitatea codului
		Return llValid
	Endif

	If !m.llValid
		AMESSAGEBOX('Codul ' + m.lcCod + ' este ' + Iif(llValid, 'valid.', 'invalid.'), 0 + 48, _Screen.Caption)
	Else
		*!* DOAR PENTRU CIF-URI VERIFIC DENUMIREA, REG_COMERT, CALITATEA DE PLATITOR TVA
		If llIsCIF
			lcXml = loVerificare.Verificare('CIF', m.lcCod, 'MFINVIES')
			If Type('loVerificare.oEntitate') = 'O'
				loPartener = loVerificare.oEntitate
				llPlatitorTva = loPartener.platitortva
				lcEroare = loPartener.eroare
				If !Empty(loPartener.eroare)
					AMESSAGEBOX(loPartener.eroare, 0 + 48, _Screen.Caption)
				Else
					lcText = 'VERIFICARE CIF: ' + m.lcCod + ' ' + m.lcDenumire + CRLF + CRLF + ;
						Alltrim(loPartener.firma) + CRLF + ;
						Iif((loPartener.platitortvamfin And Left(m.lcCod, 2) <> 'RO') Or (!loPartener.platitortvamfin And Left(m.lcCod, 2) = 'RO'), ' *** ATENTIE *** ', '') + ;
						Iif(loPartener.platitortvamfin, "PLATITOR TVA (" + Alltrim(loPartener.datatvamfin) + ")", "NEPLATITOR TVA") +  CRLF + ;
						Iif(loPartener.VIES, Iif(loPartener.platitortva, 'PLATITOR TVA VIES', 'NEPLATITOR TVA VIES'), 'Nu s-a interogat VIES.') + CRLF + ;
						'Stare: ' + Alltrim(loPartener.stare) + CRLF + ;
						'----------------------------------------------------' + CRLF + ;
						'* Adresa: ' + Alltrim(loPartener.adresa) + CRLF + ;
						'* Judet: ' + loPartener.judet + CRLF + ;
						'* Nr. inregistrare la Registrul Comertului: ' + loPartener.regcom + CRLF + ;
						'* Cod Postal: ' + loPartener.codpostal + CRLF + ;
						'* Telefon: ' + loPartener.telefon + CRLF + ;
						'* Fax: ' + loPartener.fax + CRLF + CRLF + CRLF

					AMESSAGEBOX(lcText, 0 + 64, _Screen.Caption)
				Endif
			Endif
		Endif && llIsCIF
	Endif && !llValid

	Return m.llValid
Endproc && nom_parteneri_verifica

*************************************************************
*** se apeleaza din cauta_alfa_form, butonul but_copiaza
Procedure nom_parteneri_copiaza
	Lparameters toPartener, tnIdTipPart, tnTipPersoana, tnSpecial, tcTipPart

	Local lcTipPart, lnIdPart, lnIdPartCoresp, lnIdTipPart, lnSpecial, lnTipPersoana, loDate
	lnIdTipPart = Iif(Empty(tnIdTipPart), 0, tnIdTipPart)
	lcTipPart = Iif(Empty(Nvl(tcTipPart, [])), '', tcTipPart)
	lnSpecial = Iif(Empty(tnSpecial), 0, tnSpecial)
	lnTipPersoana = Iif(Empty(tnTipPersoana), 0, tnTipPersoana)
	lnIdPartCoresp = 0
	loDate = Null
	lnIdPart = Nvl(toPartener.id_part, 0)

	If Empty(m.lnIdPart)
		Return 2
	Endif

	Do nom_parteneri_nou With m.lnIdTipPart, m.lcTipPart, m.lnSpecial, m.lnTipPersoana, m.lnIdPartCoresp, m.loDate, m.lnIdPart

	Return gnButon
Endproc && nom_parteneri_copiaza
**************************************************************************************************************************
Procedure NOM_LIMBI_NOU
	Local loRec
	Store '' To loRec
	loRec = poRec

	Do Adauga_Modifica_Inregistrare With "nom_limbi", loRec, , "INSERT", , "addlimba"
Endproc
**************************************************************************************************************************
**************************************************************************************************************************
Procedure NOM_cursuri_NOU
	Local loRec
	Store '' To loRec
	loRec = poRec

	Do Adauga_Modifica_Inregistrare With "curscal", loRec, , "INSERT", , "addnomcurs"
Endproc
**************************************************************************************************************************