***-----------------------------------------------------------------------------------------------------------
PROCEDURE fisa_lichidare

	PRIVATE pcTitlu &&, pcDataOra
	STORE "" TO pcTitlu &&, pcDataOra
	LOCAL lcOrder, lcOrderColumn, loColumnSort
	lcOrder = ""
	lcOrderColumn = ""

	PRIVATE pnId_responsabil
	STORE 0 TO pnId_responsabil

	loResp = caut_responsabil(.T.)
	pnId_responsabil = loResp.id_responsabil


	lcTitlu = [FISA DE LICHIDARE]

	pcTitlu = ceretitlu_rap([Titlul raportului],lcTitlu)
*!*		pcDataOra = get_ora(2)

	pcGrupGest = [nresp]
	pcGrupCont = [EOF()]
	pcGrupAcont = [EOF()]
	pcHeaderGrup = [Responsabil ]

	lcOrder = "nresp,denumire,codmat"

	lcSql = []
	* SELECT * from crsStocuri INTO CURSOR crs_rap ORDER BY &lcOrder
	***-------------------------------
	lcSel = [{call pack_gest_rapoarte.fisa_ob_inventar_resp_stoc(?gnAn, ?gnLuna, ?pnId_responsabil,?gnIdSucursala)}]
	lcCursor = 'cFisa'
	lnSucces = goExecutor.oExecute(lcSel,lcCursor)

	IF lnSucces < 0
		AMESSAGEBOX('Call pack_gest_rapoarte.fisa_ob_inventar_resp' + CHR(13) + goExecutor.cEroare,0+16,"Eroare")
		RETURN
	ENDIF
	***-------------------------------
	** raportul nu calcula bine totalurile
	SELECT *, ;
		IIF(dnf<>0,(dnf-(dns_luni-IIF(!EMPTY(datain) AND !ISNULL(datain),((gnAn*12+gnLuna)-(YEAR(datain)*12+MONTH(datain))),0)))/dnf*100,0000) AS uzura ;
		FROM cFisa ;
		INTO CURSOR sel1 READWRITE

	IF USED('cFisa')
		USE IN cFisa
	ENDIF

	SELECT *, ;
		IIF(uzura <= 100,ROUND((cants+CANT-CANTE)*PRET - (cants+CANT-CANTE)*PRET* uzura/100,gnPC),0) AS val_ramas ;
		FROM sel1 ;
		INTO CURSOR cFisaLic

	IF USED('sel1')
		USE IN sel1
	ENDIF


*!*		SELECT cFisaLic
*!*		REPORT FORMAT fisa_lichidare.FRX TO PRINTER PROMPT NOCONSOLE PREVIEW
	goExport.export2frx([cFisaLic],[fisa_lichidare])

	IF USED('cFisaLic')
		USE IN cFisaLic
	ENDIF


ENDPROC && fisa_lichidare
***-----------------------------------------------------------------------------------------------------------
PROCEDURE fisa_echip_uzat_pred_imputat
*!*	comentarii : 19.02.2008
	PARAMETERS tnOperatie

	&& tnOperatie: 1 - uzat; 2 - predat
	
	PRIVATE pnOperatie
	pnOperatie = tnOperatie

	LOCAL lcRaport
	lcRaport = []
	
	PRIVATE pcTitlu, pcPerioada	&&	, pcDataOra && pt. raport
	STORE "" TO pcTitlu
*!*		pcDataOra = get_ora(2)

	PRIVATE pnId_responsabil
	STORE 0 TO pnId_responsabil

	loResp = caut_responsabil(.T.)
	pnId_responsabil = loResp.id_responsabil

	***-------------------------------
	PRIVATE pdDataI, pdDataF
	STORE {} TO pdDataI, pdDataF

	loLuna = get_oluna(gnAn, gnLuna)
	lcLuna1 = PADL(loLuna.lunamin,2,'0') + PADL(loLuna.anmin,4,'0')
	lcLuna2 = PADL(loLuna.lunamax,2,'0') + PADL(loLuna.anmax,4,'0')

	LOCAL lcData1
	lcData1 = '01/'+PADL(loLuna.lunamin,2,'0')+'/'+ALLTRIM(STR(loLuna.anmin))
	pdDataI = CTOD(lcData1)
	pdDataF = ULTIMAZI(STR(loLuna.anmax), STR(loLuna.lunamax))


	ofrmperioada = CREATEOBJECT('frm_perioada_zzllaaaa')
	ofrmperioada.pdDataI = pdDataI
	ofrmperioada.pdDataF = pdDataF
	ofrmperioada.SHOW(1)
	IF gnButon=2
		RETURN
	ENDIF

	pcPerioada = DTOC(pdDataI) + ' - ' + DTOC(pdDataF)
	
	PRIVATE pnNnir 
	pnNnir = 0

	***-------------------------------
	lcSel = [{call pack_gest_rapoarte.fisa_echip_uzat_pred_imputat(?gnAn, ?gnLuna, ?pnNnir, ?pdDataI, ?pdDataF, ?pnId_responsabil, ?pnOperatie, ?gnIdSucursala)}]
	lcCursor = 'cFisa'
	lnSucces = goExecutor.oExecute(lcSel,lcCursor)

	IF lnSucces < 0
		AMESSAGEBOX(goExecutor.cEroare,0+16,"Eroare")
		RETURN
	ENDIF
	***-------------------------------
*!*		DO CASE
*!*			CASE pnOperatie = 1
*!*				pcTitlu = "FISA ECHIPAMENT UZAT"
*!*			CASE pnOperatie = 2
*!*				pcTitlu = "FISA ECHIPAMENT PREDAT"
*!*			CASE pnOperatie = 3
*!*				pcTitlu = "FISA ECHIPAMENT IMPUTAT"
*!*		ENDCASE

	PRIVATE pcSemnaturi
	STORE '' TO pcSemnaturi

	DO CASE
		CASE pnOperatie = 1
			pcTitlu = [FISA ECHIPAMENT UZAT]
			lcRaport = [rap_echip_uzat]
			param_listari(lcRaport,,@pcSemnaturi)
*!*				SELECT cFisa
*!*				REPORT FORM rap_echip_uzat TO PRINTER PROMPT PREVIEW
		CASE pnOperatie = 2
			pcTitlu = [FISA ECHIPAMENT PREDAT]
			lcRaport = [rap_echip_predat]
			param_listari(lcRaport,,@pcSemnaturi, .T.)
*!*				SELECT cFisa
*!*				REPORT FORM rap_echip_predat TO PRINTER PROMPT PREVIEW
		CASE pnOperatie = 3
			pcTitlu = [FISA ECHIPAMENT IMPUTAT]
			lcRaport = [rap_echip_imputat]
			param_listari(lcRaport,,@pcSemnaturi, .T.)
*!*				SELECT cFisa
*!*				REPORT FORM rap_echip_imputat TO PRINTER PROMPT PREVIEW
	ENDCASE

	goExport.export2frx([cFisa],lcRaport)

	IF USED("cFisa")
		USE IN cFisa
	ENDIF


ENDPROC && fisa_echip_uzat_pred_imputat
***-----------------------------------------------------------------------------------------------------------




