*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="stoc.mnx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*<MenuType>4</MenuType>
*<MenuLocation>REPLACE</MenuLocation>

*<MenuCode>
DEFINE POPUP Shortcut SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF Shortcut PROMPT "In luna curenta"
ON SELECTION BAR 1 OF Shortcut DO BAR_1_OF_Shortcut_FB2P

DEFINE BAR 2 OF Shortcut PROMPT "De la luna-la luna..."
ON SELECTION BAR 2 OF Shortcut DO BAR_2_OF_Shortcut_FB2P

DEFINE BAR 3 OF Shortcut PROMPT "In luna curenta pana la ziua..."
ON SELECTION BAR 3 OF Shortcut DO BAR_3_OF_Shortcut_FB2P
ACTIVATE POPUP Shortcut

*</MenuCode>

*<Procedures>
PROCEDURE BAR_1_OF_Shortcut_FB2P
	osetgest.tbrprim.buton5.click
ENDPROC && BAR_1_OF_Shortcut_FB2P

PROCEDURE BAR_2_OF_Shortcut_FB2P
	SET CENTURY on
	SET DATE TO dmy
	
	LOCAL a1,l1,a2,l2,inceput,sfirsit,ll,aa,cond,d1,d2
	STORE '' TO a1,l1,a2,l2,inceput,sfirsit,ll,aa,cond
	STORE DATE() TO d1,d2
	
	ll=m.nl
	aa=m.an
	
	inceput=cereluna('Alegeti luna de inceput')
	l1=LEFT(inceput,2)
	a1=RIGHT(inceput,4)
	
	sfirsit=cereluna('Alegeti luna de sfarsit')
	l2=LEFT(sfirsit,2)
	a2=RIGHT(sfirsit,4)
	
	z='01/'+l1+'/'+a1
	d1=CTOD(z)
	z='01/'+l2+'/'+a2
	d2=CTOD(z)
	d2=GOMONTH(d2,1)
	
	cond='(dataireg>=d1 and dataireg<d2)'
	*WAIT WINDOW l1+a1+'-'+l2+a2
	
	&& generare stoc 
	m.nl=l1
	m.an=a1
	
	SELECT stoc
	COPY STRUCTURE TO &loc\&nfscurt\tempo\stoct WITH cdx
	
	CLOSE DATABASES
	DO des WITH 'rul'
	DO des WITH 'actan'
	DO des WITH 'calendar'
	DO des WITH 'numegest'
	
	
	USE &loc\&nfscurt\tempo\stoct IN 0 ALIAS stoc ORDER tag denumire
	
	select DISTINCT cod,dataireg FROM actan WHERE &cond INTO CURSOR act
	SELECT * from act INTO TABLE &loc\&nfscurt\tempo\w50 
	SELECT w50
	INDEX ON cod TAG cod OF &loc\&nfscurt\tempo\w50 
	
	
	SELECT * from rul ;
	WHERE cod in (select DISTINCT cod FROM act);
	 INTO table &loc\&nfscurt\tempo\rull 
	COPY FILE &dirgen\_alfa\an0000\date00\rull.cdx TO &loc\&nfscurt\tempo\rull.cdx
	
	SELECT rull
	SET INDEX TO &loc\&nfscurt\tempo\rull.cdx
	reindex
	
	sele rul
	SET FILTER TO
	sele rulL
	SET FILTER TO
	sele ACT
	SET FILTER TO
	sele ACTAN
	SET FILTER TO
	
	do refstint 
	
	&&-------
	SELE RUL
	SET FILTER TO
	SELE ACTAN
	SET FILTER TO
	SELE RULL
	SET FILTER TO
	SELE STOC
	SET FILTER TO
	
	
	sele rul
	set relation off into actan
	SET ORDER TO TAG Cod OF &calefirma\datean\actan.cdx IN Actan
	sele rul
	SET RELATION TO cod INTO Actan ADDITIVE
	
	titlu='In perioada:'+l1+'/'+a1+'-'+l2+'/'+a2
	do form afstoc
	
	set relation off into actan
	
	
	m.an=aa
	m.nl=ll
	DO totv
ENDPROC && BAR_2_OF_Shortcut_FB2P

PROCEDURE BAR_3_OF_Shortcut_FB2P
	LOCAL aa,ll
	ll=m.nl
	aa=m.an
	
	DO stoc_data IN PROCEDURI.PRG
	&&-------
	
	SELE RULL
	SET FILTER TO
	SELE STOC
	SET FILTER TO
	
	USE IN stoc
	USE &loc\&nfscurt\tempo\inloc IN 0 ALIAS stoc ORDER tag denumire
	
	sele rul
	set relation off into actan
	SET ORDER TO TAG Cod OF &calefirma\datean\actan.cdx IN Actan
	sele rul
	SET RELATION TO cod INTO Actan ADDITIVE
	
	*titlu='Pana la data de:'+DTOC(
	do form afstoc
	
	set relation off into actan
	
	
	m.an=aa
	m.nl=ll
	DO totv
ENDPROC && BAR_3_OF_Shortcut_FB2P

*</Procedures>
