*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="achi3.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 "\Pe baza de fisa tehnologica"
ON SELECTION BAR 1 OF Shortcut DO BAR_1_OF_Shortcut_FB2P

DEFINE BAR 2 OF Shortcut PROMPT "\Pe baza de \<deviz"
ON SELECTION BAR 2 OF Shortcut lans(82)

DEFINE BAR 3 OF Shortcut PROMPT "Productie \<proprie" ;
	MESSAGE "345:711"
ON SELECTION BAR 3 OF Shortcut lans(100)

DEFINE BAR 4 OF Shortcut PROMPT "\<Inregistrare prod. cu inchidere prod. in curs" ;
	MESSAGE "345:711;711:331"
ON SELECTION BAR 4 OF Shortcut lans(219)

DEFINE BAR 5 OF Shortcut PROMPT "\-"
ON BAR 5 OF Shortcut ACTIVATE POPUP _6vh12wqmo

	*----------------------------------
	DEFINE POPUP _6vh12wqmo SHORTCUT RELATIVE
DEFINE BAR 6 OF Shortcut PROMPT "Semifabricate" ;
	MESSAGE "341:711"
ON SELECTION BAR 6 OF Shortcut lans(277)
ACTIVATE POPUP Shortcut

*</MenuCode>

*<Procedures>
PROCEDURE BAR_1_OF_Shortcut_FB2P
	*!*	LOCAL lmarca, lcant,LNUME,LCOD,lsuma,ldata
	*!*	STORE .F. TO lmarca
	*!*	STORE {} TO ldata
	*!*	DO sterge
	*!*	buton=1
	*!*	m.FDOC='PROCES VERBAL PRODUCTIE'
	
	
	*!*	lans(77)
	
	*!*	IF buton=2
	*!*		DO sterge
	*!*		RETURN
	*!*	ENDIF
	*!*	SELE numegest
	*!*	LOCA FOR numegest=m.numegest
	*!*	m.GESTDEST=GEST
	*!*	ldata=M.DATAACT
	
	*!*	OP_GEST.SELECTIE_achi()&&materiale
	
	
	*!*	DO CAUT_ALFA_CURSOR WITH 'NUMEGEST','NUMEGEST','Gestiunea sursa de materiale:','m.numegest'
	*!*	m.GESTSURSA=GEST
	
	*!*	OP_GEST.PAGEFR1.SELECTIE(NR_GEST)
	
	*!*	SELECT INTRARI
	*!*	ZAP
	*!*	OB=CREATEOBJECT("FACTGEST_RETETAR")
	*!*	OB.SHOW(1)
	
	
	*!*	IF buton=2
	*!*		DO sterge
	*!*		RETURN
	*!*	ENDIF
	
	
	
	
	*!*	SELECT INTRARI
	*!*	SCAN
	*!*		m.ID_PRODUS=VAL(sectie)
	*!*		CANTITATE=CANT
	
	*!*		SELECT DISTINCT codmat,denumire,UM,SUM(cants+CANT-cantE) AS cants FROM stoc WHERE GEST=M.GESTSURSA INTO CURSOR STOCTOTAL;
	*!*		GROUP BY denumire,codmat
	
	*!*		SELECT retetar
	*!*		SCAN FOR ID_PRODUS=m.ID_PRODUS AND !DELETED()
	*!*			SCATTER MEMVAR
	*!*			pcant=CANTITATE*m.CANT
	
	*!*			SELECT STOCTOTAL
	*!*			LOCATE FOR denumire=m.denumire AND codmat=m.codmat
	*!*			IF !FOUND() OR cants<pcant
	*!*				DO mesaj WITH "Nu e in stoc cantitatea dorita pentru ",ALLTRIM(m.codmat)+' '+ALLTRIM(m.denumire)
	*!*				lmarca=.T.
	*!*			ENDIF
	
	*!*			SELECT retetar
	*!*		ENDSCAN
	*!*		SELECT INTRARI
	*!*	ENDSCAN
	
	*!*	IF lmarca=.T.
	*!*		RETURN
	*!*	ENDIF
	
	*!*	DO codare
	*!*	SELECT INTRARI
	*!*	REPLACE ALL cod WITH m.cod
	
	*!*	SELECT INTRARI
	*!*	SCAN
	*!*		m.ID_PRODUS=VAL(sectie)
	*!*		CANTITATE=CANT
	*!*		STORE .F. TO lmarca
	*!*		STORE 0 TO lcant
	*!*		STORE " " TO LNUME,LCOD
	
	*!*		CREATE TABLE  &LOC\&NFSCURT\TEMPO\retete.DBF (denumire c(100),codmat c(50),CANT N(10,3),cantE N(14,3), pretu N(14,2), pret N(14,2),UM c(6))
	
	*!*		SELECT retetar
	*!*		SCAN  FOR ID_PRODUS=m.ID_PRODUS AND !DELETED()
	*!*			SCATTER MEMVAR
	*!*			pcant=CANTITATE*m.CANT
	*!*	*
	*!*			SELECT retete
	*!*			APPEND BLANK
	*!*			GATHER MEMVAR
	*!*			REPLACE cantE WITH pcant
	
	*!*			SELECT retetar
	*!*		ENDSCAN
	
	*!*		SELECT S.UM,S.pret AS pret,S.pret AS pretTOT,S.SCD,S.denumire,S.codmat,S.cants+S.CANT-S.cantE AS cantE,R.cantE AS CANTTOT;
	*!*		FROM stoc S JOIN retete R ON S.denumire=R.denumire AND S.codmat=R.codmat;
	*!*		WHERE S.GEST=M.GESTSURSA AND (S.cants+S.CANT-S.cantE)>0;
	*!*		INTO TABLE &LOC\&NFSCURT\TEMPO\AAA ORDER BY R.denumire,R.codmat
	
	
	*!*		SELECT AAA
	*!*		SCAN
	*!*			DO CASE
	*!*				CASE ALLTRIM(denumire)=LNUME AND ALLTRIM(codmat)=LCOD AND !lmarca
	*!*					REPLACE cantE WITH 0
	*!*					REPLACE CANTTOT WITH 0
	*!*					REPLACE pretTOT WITH 0
	
	*!*				CASE cantE>=CANTTOT AND !lmarca &&AND DENUMIRE!=LNUME AND CODMAT!=LCOD
	
	*!*					REPLACE cantE WITH CANTTOT
	*!*					REPLACE pretTOT WITH CANTTOT*pret
	*!*					LNUME=ALLTRIM(denumire)
	*!*					LCOD=ALLTRIM(codmat)
	
	*!*				CASE cantE<CANTTOT AND !lmarca &&AND DENUMIRE!=LNUME AND CODMAT!=LCOD
	
	*!*					lcant=CANTTOT-cantE
	*!*					lmarca=.T.
	*!*					REPLACE pretTOT WITH cantE*pret
	*!*				CASE lmarca AND cantE>=lcant
	
	*!*					REPLACE cantE WITH lcant
	*!*					REPLACE pretTOT WITH lcant*pret
	*!*					lmarca=.F.
	*!*					LNUME=ALLTRIM(denumire)
	*!*					LCOD=ALLTRIM(codmat)
	
	*!*				CASE lmarca AND cantE<lcant
	
	*!*					lcant=lcant-cantE
	*!*					REPLACE pretTOT WITH cantE*pret
	*!*			ENDCASE
	*!*		ENDSCAN
	
	
	*!*		SELECT iesiri
	*!*		ZAP
	*!*		APPEND FROM &LOC\&NFSCURT\TEMPO\AAA.DBF FOR cantE#0   &&FIELDS codmat,denumire,UM,pret,cantE
	
	*!*		SELECT iesiri
	*!*		REPLACE ALL nnir WITH m.nnir,DATAACT WITH ldata, cod WITH m.cod,GEST WITH m.GESTSURSA,;
	*!*		sectie WITH STR(m.ID_PRODUS)
	*!*		SELECT iesiri
	*!*		SUM pret*cantE TO lsuma
	*!*		SUM pret TO LSUMAP
	*!*		m.DATAACT=ldata
	*!*		DO contabilizeaza WITH '601','301',lsuma
	*!*		SELECT iesiri
	*!*		DO iestocurimagazii
	*!*		DO ierulajmagazii
	
	*!*		SELECT INTRARI
	*!*		REPLACE pret WITH lsuma/CANTITATE
	*!*		REPLACE VALFTVA WITH CANT*lsuma/CANTITATE
	*!*	ENDSCAN
	
	*!*	SELECT INTRARI
	*!*	*REPLACE ALL nrord WITH ""
	*!*	m.DATAACT=ldata
	*!*	PRIVATE pnsuma
	
	*!*	SUM VALFTVA TO pnsuma
	*!*	m.EXPLICATIA=M.nume_4
	
	*!*	DO contabilizeaza WITH "345 ","711 ",pnsuma
	*!*	DO instocurimagazii
	*!*	DO inrulajmagazii
	*!*	SELECT rull
	*!*	IF FLOCK()
	*!*		REPLACE ALL nrord WITH sectie FOR cod=m.cod
	*!*		REPLACE ALL sectie WITH "" FOR cod=m.cod
	*!*	ENDIF
	*!*	UNLOCK
	
	*!*	*!*	*-------------------listare----------------------------
	*!*	*SELECT * from rull WHERE cod=m.cod INTO CURSOR bbb
	*!*	*SELECT DISTINCT * from intrari i JOIN rull r ON i.cod=r.cod AND i.nrord=r.nrord WHERE R.CANTE#0 INTO CURSOR bbb
	
	*!*	*!*	 sele *,retetar.cant as cant_p ;
	*!*	*!*	 from (rull JOIN retetar ON (VAL(rull.nrord)=retetar.id_produs AND rull.denumire=retetar.denumire));
	*!*	*!*	 WHERE rull.cod=m.cod AND rull.cante#0 INTO TABLE c:\tabel.dbf
	*!*	*DO danu WITH 'Doriti sa listati acest nir?'
	*!*	*IF buton=1
	
	*!*	LOCAL m.gest_a,m.gest_b
	*!*	STORE 0 TO m.gest_a,m.gest_b
	*!*	SELECT rull.*,retetar.CANT AS cant_p;
	*!*	FROM (rull JOIN retetar ON (VAL(rull.nrord)=retetar.ID_PRODUS AND rull.denumire=retetar.denumire));
	*!*	WHERE rull.cod=m.cod AND rull.cantE#0 INTO TABLE &LOC\&NFSCURT\TEMPO\tabel.DBF
	
	*!*	SELECT * FROM tabel T JOIN rull R ON T.nrord=R.nrord AND T.cod=R.cod WHERE R.cantE=0 INTO CURSOR bbb
	
	*!*	SELECT bbb
	*!*	GO TOP
	*!*	SCATTER FIELDS gest_a,gest_b MEMVAR
	
	*!*	SELECT numegest
	*!*	LOCATE FOR GEST=m.gest_a
	*!*	m.numegest=numegest
	*!*	LOCATE FOR GEST=m.gest_b
	*!*	gestfix=numegest
	*!*	SELECT bbb
	*!*	REPORT FORM bontransfer TO PRINTER PROMPT PREVIEW
	*!*	*ENDIF
	
	*!*	*!*	*------------------/listare---------------------------
	
	*!*	USE IN AAA
	*!*	USE IN retete
	*!*	USE IN tabel
	*!*	DELETE FILE &LOC\&NFSCURT\TEMPO\tabel.DBF
	
	*!*	DO sterge
ENDPROC && BAR_1_OF_Shortcut_FB2P

*</Procedures>
