**********************************************************************
* Program....: OMENIU_INITIALIZARI.PRG
* Version....: 
* Author.....: MMUTU # marius.mutu
* Date.......: 15 June 2006, 15:21:31
* Notice.....: Copyright © 2006, 
* All Rights Reserved.
* Compiler...: Visual FoxPro 09.00.0000.2412 for Windows
* Abstract...: 
* Changes....: marius.mutu, Created 15 June 2006 / 15:21:31
* Parameters.: 
* called by..: 
* Purpose....: 
**********************************************************************


*------------------------------------------------------------
* Description: configurare_note
* Parameters:  tlCRM
* Return:      
* Use:         
*------------------------------------------------------------
* Id Date        By         Description
*  1 10/12/2004  lavinia.viziru Initial Creation
* 
*------------------------------------------------------------
Procedure configurare_note
	Parameters tlCRM

	Local llCRM
	Local ofrm_note As Form
	Local lcCursor, lcCursor0, lcFiltru, lcForm, lcOrder, lcSchema, lcSelect, lcSelect0, lnSucces
	Local lnSucces0
	llCRM = tlCRM && folosesc crm_note_vanzari de pe server

	***-----------------------------------------------------------------------------------------------------------------------------
	If llCRM
		Private poNote_vanzari
		Store '' To poNote_vanzari

		Local lcSchema1, lcSelect1, lcOrder1, lcFiltru1, llAfiseaza, lcgroup, llModParam, lcFiltruOriginal
		lcSchema1 = []
		lcSelect1 = [select denumire as meniu, nv.* from vcrm_note_vanzari nv]
		lcOrder1 = [denumire]
		lcgroup = []
		lcFiltru1 = []
		lcFiltruOriginal = []
		llModParam = .T.
		llAfiseaza = .F.

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

	Else

		Select nom_meniu
		Set Order To 3 && Meniu
		Go Top
	Endif
	***-----------------------------------------------------------------------------------------------------------------------------
	lcSelect0 = [select cont, acont from ] + gcS + [.plcont where an = ] + Alltrim(Str(gnAn))
	lcCursor0 = [cplcont]

	lnSucces0 = goExecutor.oExecute(lcSelect0, lcCursor0)
	If lnSucces0 < 0
		aMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
		Return
	Endif
	***-----------------------------------------------------------------------------------------------------------------------------
	Private ponote_contab, pcschema, pcselect
	Store '' To ponote_contab
	lcSchema1 = []
	lcSelect1 = [select * from ] + Iif(gnAn >= Iif(Type('gnAnFormNou') = 'U', 2007, gnAnFormNou), [vnote_contabile], [note_contabile])
	lcOrder1 = [id_set, ordine]
	lcgroup = []
	lcFiltru1 = []
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	***************************************************************
	*** Note definite de utilizator
	***************************************************************
	Private poCategorii
	poCategorii = Null
	lcSchema = []
	lcSelect = [select categorie, id_categorie, ordine from xSetsCategorii where sters = 0 union select 'FARA CATEGORIE' as categorie, 0 as id_categorie, 0 as ordine from dual]
	lcOrder = [ordine]
	lcgroup = []
	lcFiltru = [1=2]
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	Private poSets
	poSets = Null
	lcSchema = []
	lcSelect = [select * from xSets]
	lcOrder = [nume_set]
	lcgroup = []
	lcFiltru = [1=2]
	lcFiltruOriginal = [id_set >= 1000000]
	llModParam = .T.
	llAfiseaza = .F.

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

	Private poRequest
	poRequest = Null
	lcSchema = []
	lcOrder = [r.nr_item]
	lcgroup = []
	lcFiltru = [1=2]
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

	Text To lcSelect Textmerge Noshow
	select i.label_item,
	       s.nume_set,
	       r.valoare_default,
	       r.nr_item,
	       r.id_item,
	       r.id_set,
	       i.fis_lista,
	       i.id_fisier,
	       i.camp_lista,
      	   rpad(case
              when i.fis_lista is not null then
               pack_util.GetText(i.fis_lista,
                                 i.id_fisier,
                                 CASE WHEN LENGTH(TRIM(TRANSLATE(r.valoare_default, '0123456789+-.', ' '))) IS NULL 
                                      THEN to_number(r.valoare_default)
                                      ELSE 0
                                 END,  
                                 replace(i.camp_lista, ',', ' || '' '' || '))
              ELSE
               r.valoare_default
           end,
           100,
           ' ') as valoare_default_text
	  from xrequest r
	  join xsets s
	    on s.id_set = r.id_set
	  join xitems i
	    on i.id_item = r.id_item
	Endtext

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

	Private poNote
	poNote = Null
	lcSchema = []
	lcOrder = [a.nr_nota]
	lcgroup = []
	lcFiltru = [1=2]
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.
	
	Text To lcSelect Textmerge Noshow
        SELECT decode(NVL(a.id_jtva_coloana, 0), 0, 0, 1) As Cu_tva, 
           Cast(0 As Number(2)) As tipnota,
             cast(0 as number(20)) as id_act,
             cast(0 as number(2)) as luna,
             cast(0 as number(4)) as an,
             cast(0 as number(20)) as cod,
             a.dataireg,
             a.serie_act,
             a.nract,
             a.dataact,
             a.explicatia,
             a.xscd as scd,
             a.xascd as ascd,
             a.xscc as scc,
             a.xascc as ascc,
             a.suma,
             a.pereched,
             a.perechec,
             a.suma_val,
             a.id_valuta,
             v.nume_val,
             a.curs,
             a.datascad,
             0 AS neimpozab,
             a.nnir,
             cast(0 as number(5)) as id_util,
             '' AS util,
             sysdate as dataora,
             cast(0 as number(5)) as id_utils,
             '' AS utils,
             sysdate as dataoras,
             a.id_responsabil,
             resp.denumire AS nresp,
             a.id_venchelt,
             venchelt.explicatie AS dst_chlt,
             a.id_lucrare,
             lucr.nrord,
             a.id_ctr,
             (case when ctr.numar is not null then ctr.numar || '/' else '' end) || TO_CHAR(ctr.data,'DD.MM.YYYY') as contract,
             a.id_sectie,
             sectii.sectie,
             a.proc_tva,
             a.id_set,
             NVL(a.id_fact, 0) as id_fact,
             a.id_partd,
             part1.denumire AS partd,
             a.id_partc,
             part.denumire AS partc,
             cast(0 as number(5)) as id_sucursala,
             '' as sucursala,
             a.id_fdoc,
             fdoc.fel_document AS fdoc,
             a.explicatia4,
             a.explicatia5,
             cast(0 as number(5)) as id_gestin,
             '' AS gestin,
             cast(0 as number(5)) as id_gestout,
             '' AS gestout,
             NVL(a.id_factd, 0) as id_factd,
             NVL(a.id_factc, 0) as id_factc,
             a.id_jtva_coloana,
             jtva.denumire as explicatie_tva,
             cast(0 AS NUMBER(1)) AS validat,
             cast(0 as number(5)) as id_utilv,
             '' as utilv,
             SYSDATE AS dataorav,
             NVL(doc.tva_incasare,0) as tva_incasare
             from xnote a 
          LEFT JOIN nom_fdoc fdoc ON a.id_fdoc = fdoc.id_fdoc
          LEFT JOIN nom_parteneri part ON a.id_partc = part.id_part
          LEFT JOIN nom_parteneri part1 ON a.id_partd = part1.id_part
          LEFT JOIN vnom_venchel venchelt ON a.id_venchelt = venchelt.id_venchelt
          LEFT JOIN nom_parteneri resp ON a.id_responsabil = resp.id_part
          LEFT JOIN nom_sectii sectii ON a.id_sectie = sectii.id_sectie
          LEFT JOIN vnom_lucrari lucr ON a.id_lucrare = lucr.id_lucrare
          LEFT JOIN nom_valute v ON a.id_valuta = v.id_valuta
		  LEFT JOIN contracte ctr ON ctr.id_ctr = a.id_ctr          
          LEFT JOIN jtva_coloane jtva ON a.id_jtva_coloana = jtva.id_jtva_coloana
          LEFT JOIN documente doc on a.id_fact = doc.id_doc        	
	Endtext
	gencursor('poNote', 'crsENote', lcSelect, lcFiltru, lcSchema, lcOrder, llAfiseaza,  lcgroup, llModParam, lcFiltruOriginal)
	poNote.ca_baza1.afisare()
	***************************************************************


	lcCursor0 = [ctva]
	lcCursor = [ccalendar]
	If gnAn >= Iif(Type('gnAnFormNou') = 'U', 2007, gnAnFormNou)
		lcForm = [frm_config_note_contabile2007]
	Else
		lcSelect0 = [select descriere as tva, procent as ptva from ] + gcS + [.cote_tva where an = ?gnAn and luna = ?gnLuna]
		lnSucces0 = goExecutor.oExecute(lcSelect0, lcCursor0)
		If lnSucces0 < 0
			aMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
			Return
		Endif

		lcSelect = [select ctvam from ] + gcS + [.calendar where an = '] + Alltrim(Str(gnAn)) + ;
			[' and nl = '] + Alltrim(Str(gnAn)) + [']
		lnSucces = goExecutor.oExecute(lcSelect, lcCursor)
		If lnSucces < 0
			aMESSAGEBOX(goExecutor.cEroare, 0 + 16, 'Eroare')
			Return
		Endif

		Private pnctvam
		Select ccalendar
		pnctvam = ccalendar.ctvam

		lcForm = [frm_config_note_contabile]
	Endif
	*ofrm_note = CREATEOBJECT(lcForm,llCRM)
	Do Form (lcForm) Name ofrm_note Linked With m.llCRM Noshow
	ofrm_note.Show(1)


	Release ponote_contab
	Use In (select(lcCursor0))
	Use In (select(lcCursor))
	Use In (SELECT('cnote_contab'))
	If m.llCRM
		Use In (SELECT('nom_meniu'))
	ENDIF
	USE IN (select('crsECategorii'))
	USE IN (select('crsESets'))
Endproc
******************************* SFARSIT: configurare_note ************************************


*------------------------------------------------------------
* Description: configurare analitice
* Parameters:  
* Return:      
* Use:         
*------------------------------------------------------------
* Id Date        By         Description
*  1 15/06/2006  marius.mutu Initial Creation
* 
*------------------------------------------------------------
Procedure configurare_analitice

	Private poConfig
	Local lcSchema, lcSelect, lcOrder, lcgroup, lcFiltru, lcFiltruOriginal, llModParam, llAfiseaza
	Store Null To poConfig
	lcSchema = []
	lcSelect = [select * from config_analitice]
	lcOrder = [cont]
	lcgroup = []
	lcFiltru = []
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	loConfigFrm = Createobject("frm_config_analitice")
	loConfigFrm.Show(1)
Endproc && configurare_analitice

*------------------------------------------------------------
Procedure configurare_analitice_gruputil

	Private poConfig
	Local lcSchema, lcSelect, lcOrder, lcgroup, lcFiltru, lcFiltruOriginal, llModParam, llAfiseaza
	Store Null To poConfig
	lcSchema = []
	lcSelect = [select * from vconfig_gruputil_analitice]
	lcOrder = [denumire_grup, cont]
	lcgroup = []
	lcFiltru = []
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	loConfigFrm = Createobject("frm_config_analitice_gruputil")
	loConfigFrm.Show(1)

	USE IN (SELECT('crsConfigAnalitice'))
Endproc && configurare_analitice_gruputil

*------------------------------------------------------------
Procedure configurare_analitice_tva

	Private poConfig
	Local lcSchema, lcSelect, lcOrder, lcgroup, lcFiltru, lcFiltruOriginal, llModParam, llAfiseaza
	Store Null To poConfig
	lcSchema = []
	lcSelect = [select id, id_jtva_coloana, explicatie_tva, cont, acont, id_grup, denumire_grup, id_sucursala, sucursala, id_util, utilizator, dataora from vconfig_tva_analitice]
	lcOrder = [sucursala, denumire_grup, cont, explicatie_tva]
	lcgroup = []
	lcFiltru = []
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	loConfigFrm = Createobject("frm_config_analitice_tva")
	loConfigFrm.Show(1)
	
	USE IN (SELECT('crsConfigAnalitice'))
Endproc && configurare_analitice_tva

* Eof OMENIU_INITIALIZARI.PRG



*******************************************
* PROCEDURE acces_liste(  )
* Date : 08/30/06, 11:37:08
* author : liana.macinic
* description: 

****** PARAMETER BLOCK **************
* Parameters : 0
* 
*******************************************
Procedure acces_liste(  )
	Private poAccesListe
	Local lcSchema, lcSelect, lcOrder, lcgroup, lcFiltru, lcFiltruOriginal, llModParam, llAfiseaza
	Store Null To poAccesListe
	lcSchema = []
	lcSelect = [select * from vpolitici_grupuri]
	lcOrder = [nume_lista_preturi]
	lcgroup = []
	lcFiltru = [1=1] + gcCondSucursala
	lcFiltruOriginal = []
	llModParam = .T.
	llAfiseaza = .F.

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

	loAccesListeFrm = Createobject("frm_politiciGrupuri")
	loAccesListeFrm.Show(1)

Endproc
*----------------------------------sfarsit procedura acces_liste----------------------------------   