PROCEDURE fisa_ob_inventar
&& tlToate - se genereaza raportul pt. toate obiectele de inventar

	SET SAFETY OFF
	
	PRIVATE pcTitlu, pcPerioada, pcDataOra && pt. raport
	
	PRIVATE pcli, pcai, pclf, pcaf && pt. forma de alegere perioada
	STORE m.nl TO pcli, pclf
	STORE m.an TO pcai, pcaf
	
	LOCAL lnnrlunii, lnnrlunif, lcprimaluna, lcprimulan, lcultimaluna, lcultimulan
	STORE 0 TO lnnrlunii, lnnrlunif
	STORE "" TO lcprimaluna, lcprimulan, lcultimaluna, lcultimulan   

	podif=CREATEOBJECT("frm_datai_dataf")
	podif.SHOW(1)
	IF buton = 2
		RETURN
	ENDIF
	
	lnnrlunii = VAL(pcai)*12+VAL(pcli)
	lnnrlunif = VAL(pcaf)*12+VAL(pclf)
	SELECT nl, an FROM calendar ;
		WHERE BETWEEN(VAL(an)*12+VAL(nl),lnnrlunii,lnnrlunif) ;
		INTO CURSOR cCalendar

	SELECT cCalendar
	IF _TALLY=0
		DO mesaj WITH "Nu exista nici o luna deschisa in perioada",pcli + '  ' + pcai + ' - ' + pclf + '  ' + pcaf
		RETURN
	ENDIF

	SELECT cCalendar
	GO TOP
	lcprimaluna = nl
	lcprimulan = an
	GO BOTTOM
	lcultimaluna = nl
	lcultimulan = an

	pcperioada = "Perioada de referinta " + "01/" + lcprimaluna + "/" + lcprimulan + " - " + DTOC(ultimazi(lcultimulan,lcultimaluna))
	
	od=CREATEOBJECT('frm_toate')
	od.label1.CAPTION='Sa se genereze situatia pentru:'
	od.cmdrenunt1.CAPTION='\<Un obiect de inventar'
	od.cmdtermin1.CAPTION='\<Toate obiectele'
	od.SHOW(1)
	
	&& trebuie sa adun datele din toate fisierele existente in perioada
	llprimaluna = .T.
	SELECT cCalendar
	SCAN 
		lcAn = an
		lcnl = nl
		lcDate = ADDBS(calefirma)+"an"+lcAn+"\date"+lcnl
		lcfisobinvent = ADDBS(lcDate)+"obinvent.dbf" 
		
		IF FILE(lcfisobinvent)
			USE (lcfisobinvent) IN 0 again ALIAS tobinvent 
			IF llprimaluna && aduc peste inregistrarile din prima luna restul inregistrarilor
				SELECT * from tobinvent INTO CURSOR obinventar_total READWRITE  
			ELSE
				SELECT * from tobinvent INTO CURSOR obinventar_partial 
				SELECT obinventar_total 
				APPEND FROM DBF("obinventar_partial")
				USE IN obinventar_partial 
			ENDIF 
			IF USED("tobinvent")
				USE IN tobinvent 
			ENDIF 	 
		ELSE
*!*				DO mesaj WITH "Nu exista fisierul "+ lcfisobinvent 
			AMESSAGEBOX("Nu exista fisierul "+lcfisobinvent+" !",0+48,"Atentie")
			RETURN 
		ENDIF 
		
		llprimaluna = .F.
	SELECT cCalendar
	ENDSCAN 
	
	USE IN cCalendar
	pcDataOra = get_ora(2)
	
	IF buton = 1 && obiectul de inventar ales
		SELE DISTINCT obinventar_total.denumire FROM obinventar_total INTO TABLE &loc\&nfscurt\tempo\tden
		INDEX ON denumire TAG denumire OF &loc\&nfscurt\tempo\tden

		DO caut_alfa_cursor WITH 'tden','denumire','Denumirea obiectului de inventar','m.denumire'
		pcTitlu = "Fisa obiectului de inventar " + ALLTRIM(m.denumire)
		
		SELE obinventar_total
		SET FILTER TO denumire = m.denumire
		REPORT FORM FISA TO PRINTER PROMPT PREVIEW
		SELE obinventar_total
		SET FILTER TO
	ELSE && toate obiectele de inventar 
		pcTitlu = "Fisa obiectelor de inventar "	
		SELE obinventar_total
		REPORT FORM FISA TO PRINTER PROMPT PREVIEW
	ENDIF
	
	USE IN obinventar_total 
	
ENDPROC && fisa_ob_inventar
***-----------------------------------------------------------------------------------------------------------
