1136 lines
41 KiB
Plaintext
1136 lines
41 KiB
Plaintext
*!* 03.08.2022
|
|
*!* rap_stocuri_pe_vechimi - includere datain in xls
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure fisa_ob_inventar_gest
|
|
Lparameters tnTipGest, tlExcel
|
|
&& tlToate - se genereaza raportul pt. toate obiectele de inventar
|
|
|
|
Set Safety Off
|
|
Private pcTitlu, pcPerioada && , pcDataOra && pt. raport
|
|
Store "" To pcTitlu
|
|
&& pcDataOra = get_ora(2)
|
|
|
|
Private pnId_gestiune, pcGestiune, pnId_articol
|
|
Store 0 To pnId_gestiune, pnId_articol
|
|
Store "" To pcGestiune
|
|
|
|
loGest = caut_gestiune(tnTipGest, gnIdUtil)
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
pcGestiune = loGest.nume_gestiune
|
|
pnId_gestiune = loGest.id_gestiune
|
|
***-------------------------------
|
|
|
|
*!* od=Createobject('frm_toate')
|
|
*!* od.label1.caption = ""
|
|
*!* od.label1.Caption='Sa se genereze situatia pentru:'
|
|
*!* *!* od.cmdrenunt1.Caption='\<Un obiect de inventar'
|
|
*!* *!* od.cmdtermin1.Caption='\<Toate obiectele'
|
|
*!* od.Show(1)
|
|
***-------------------------------
|
|
* If buton = 1 && obiectul de inventar ales
|
|
loArticol = caut_articol(tnTipGest, .T.)
|
|
pnId_articol = loArticol.id_articol
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
* Endif
|
|
***-------------------------------
|
|
*!* Private pcondper, ldata1, ldata2
|
|
*!* Store '' To pcondper
|
|
*!* * LOCAL ldata1,ldata2,lcd1,lcd2
|
|
*!* Store "" To ldata1, ldata2
|
|
*!* Local lcd1,lcd2
|
|
|
|
*!* oper = Createobject('frm_perioada')
|
|
*!* oper.lb_titlu_alb_b121.caption = "Alegeti perioada"
|
|
*!* oper._optiongrup1.Value=1
|
|
*!* oper.Show(1)
|
|
*!* Release oper
|
|
|
|
*!* If Occurs('_',pcondper)>0
|
|
*!* lpos = At('_',pcondper)
|
|
*!* ldata1 = Substr(pcondper,1,lpos-1)
|
|
*!* ldata2 = Substr(pcondper,lpos+1)
|
|
*!* lcd1 = Substr(ldata1,7,2)+'/'+Substr(ldata1,5,2)+'/'+Substr(ldata1,1,4)
|
|
*!* lcd2 = Substr(ldata2,7,2)+'/'+Substr(ldata2,5,2)+'/'+Substr(ldata2,1,4)
|
|
*!* pcPerioada='De la: '+lcd1+' pana la '+lcd2
|
|
*!* Else
|
|
*!* ldata1 = pcondper+'01'
|
|
*!* ldData = Date(Val(Substr(ldata1,1,4)),Val(Substr(ldata1,5,2)),1)
|
|
*!* ldata2 = Dtos(Gomonth(ldData,1)-1)
|
|
*!* pcPerioada='LUNA: '+Substr(ldata1,5,2)+' '+Substr(ldata1,1,4)
|
|
*!* Endif
|
|
|
|
|
|
|
|
*!* PRIVATE lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
*!* STORE 0 TO lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
|
|
*!* 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')
|
|
|
|
*!* pcondper=""
|
|
*!* ofrmperioada=CREATEOBJECT('frm_perioada_luni')
|
|
*!* WITH ofrmperioada
|
|
*!* ._textbox1.VALUE=lcLuna1
|
|
*!* ._textbox2.VALUE=lcLuna2
|
|
*!* ._optiongrup1.VALUE = 2
|
|
*!* ._optiongrup1.VALID()
|
|
*!* ENDWITH
|
|
*!* ofrmperioada.SHOW(1)
|
|
*!* IF gnButon=2
|
|
*!* RETURN
|
|
*!* ENDIF
|
|
|
|
*!* plPerioada=.F.
|
|
*!* lnPoz=AT('_',pcondper)
|
|
*!* IF lnPoz>0
|
|
*!* plPerioada=.T.
|
|
*!* ENDIF
|
|
|
|
|
|
*!* IF plPerioada
|
|
*!* lnAn1 = VAL(SUBSTR(pcondper,3,4))
|
|
*!* lnLuna1 = VAL(SUBSTR(pcondper,1,2))
|
|
*!* lnAn2 = VAL(SUBSTR(pcondper,10,4))
|
|
*!* lnLuna2 = VAL(SUBSTR(pcondper,8,2))
|
|
|
|
*!* lnInit = lnAn1 * 12 + lnLuna1
|
|
*!* lnFinal = lnAn2 * 12 + lnLuna2
|
|
*!* pcPerioada = SUBSTR(pcondper,1,2)+'/'+SUBSTR(pcondper,3,4) + ' - ' + SUBSTR(pcondper,8,2)+'/'+SUBSTR(pcondper,10,4)
|
|
*!* ELSE
|
|
*!* lnAn1 = VAL(SUBSTR(pcondper,3,4))
|
|
*!* lnLuna1 = VAL(SUBSTR(pcondper,1,2))
|
|
*!* lnAn2 = VAL(SUBSTR(pcondper,3,4))
|
|
*!* lnLuna2 = VAL(SUBSTR(pcondper,1,2))
|
|
|
|
*!* lnInit = lnAn1 * 12 + lnLuna1
|
|
*!* lnFinal = lnAn2 * 12 + lnLuna2
|
|
*!* pcPerioada = SUBSTR(pcondper,1,2)+'/'+SUBSTR(pcondper,3,4) + ' - ' + SUBSTR(pcondper,1,2)+'/'+SUBSTR(pcondper,3,4)
|
|
*!* ENDIF
|
|
|
|
***-------------------------------
|
|
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)
|
|
***-------------------------------
|
|
***-------------------------------
|
|
lcSel = [{call pack_gest_rapoarte.fisa_ob_inventar_gest(?pdDataI, ?pdDataF, ?pnId_gestiune, ?pnId_articol, ?gnIdSucursala)}]
|
|
lcCursor = 'cFisa'
|
|
lnSucces = goExecutor.oExecute(lcSel,lcCursor)
|
|
|
|
If lnSucces < 0
|
|
amessage('Call pack_gest_rapoarte.fisa_ob_inventar_gest' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
***-------------------------------
|
|
pcTitlu = "FISA DE MAGAZIE"
|
|
|
|
If tlExcel
|
|
goExport.export2xls([cFisa])
|
|
*!* Do export_xls With 'cFisa' In oproceduri_comune.prg
|
|
Else
|
|
goExport.export2frx([cFisa],[fisa_obi_gest])
|
|
*!* Select cFisa
|
|
*!* Report Form fisa_obi_gest To Printer Prompt Preview
|
|
Endif
|
|
|
|
If Used("cFisa")
|
|
Use In cFisa
|
|
Endif
|
|
|
|
Endproc && fisa_ob_inventar_gest
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure fisa_magazie
|
|
Lparameters tnTipGest
|
|
|
|
Private pcTitlu, pcPerioada &&, pcDataOra && pt. raport
|
|
Store "" To pcTitlu
|
|
&& pcDataOra = get_ora(2)
|
|
|
|
Private pnId_gestiune, pcGestiune, pnId_articol
|
|
Store 0 To pnId_gestiune, pnId_articol
|
|
Store "" To pcGestiune
|
|
|
|
loGest = caut_gestiune(tnTipGest, gnIdUtil)
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
pcGestiune = loGest.nume_gestiune
|
|
pnId_gestiune = loGest.id_gestiune
|
|
loArticol = caut_articol(tnTipGest, .T.)
|
|
pnId_articol = loArticol.id_articol
|
|
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
|
|
Private lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
Store 0 To lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
|
|
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')
|
|
|
|
pcondper=""
|
|
ofrmperioada=Createobject('frm_perioada_luni')
|
|
With ofrmperioada
|
|
._textbox1.Value=lcLuna1
|
|
._textbox2.Value=lcLuna2
|
|
._optiongrup1.Value = 2
|
|
._optiongrup1.Valid()
|
|
Endwith
|
|
ofrmperioada.Show(1)
|
|
If gnButon=2
|
|
Return
|
|
Endif
|
|
|
|
plPerioada=.F.
|
|
lnPoz=At('_',pcondper)
|
|
If lnPoz>0
|
|
plPerioada=.T.
|
|
Endif
|
|
|
|
|
|
If plPerioada
|
|
lnAn1 = Val(Substr(pcondper,3,4))
|
|
lnLuna1 = Val(Substr(pcondper,1,2))
|
|
lnAn2 = Val(Substr(pcondper,10,4))
|
|
lnLuna2 = Val(Substr(pcondper,8,2))
|
|
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,8,2)+'/'+Substr(pcondper,10,4)
|
|
Else
|
|
lnAn1 = Val(Substr(pcondper,3,4))
|
|
lnLuna1 = Val(Substr(pcondper,1,2))
|
|
lnAn2 = Val(Substr(pcondper,3,4))
|
|
lnLuna2 = Val(Substr(pcondper,1,2))
|
|
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4)
|
|
Endif
|
|
***-------------------------------
|
|
lcSel = [{call pack_gest_rapoarte.fisa_magazie(?lnAn1, ?lnLuna1, ?lnAn2, ?lnLuna2, ?pnId_gestiune, ?pnId_articol, ?gnIdSucursala)}]
|
|
lcCursor = 'cFisa'
|
|
lnSucces = goExecutor.oExecute(lcSel,lcCursor)
|
|
|
|
If lnSucces < 0
|
|
amessage('Call pack_gest_rapoarte.fisa_magazie' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
***-------------------------------
|
|
pcTitlu = "FISA DE MAGAZIE"
|
|
|
|
* SELECT * FROM cFisa INTO TABLE d:\fisa.dbf
|
|
goExport.export2frx([cFisa],[fisa_magazie])
|
|
*!* Select cFisa
|
|
*!* Report Form fisa_magazie To Printer Prompt Preview
|
|
If Used("cFisa")
|
|
Use In cFisa
|
|
Endif
|
|
|
|
Endproc && fisa_magazie
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure fisa_magazie_FIFO
|
|
Lparameters tnTipGest, tnIdGestiune, tcNumeGestiune, tnIdArticol, tcSerie
|
|
|
|
Private pcTitlu, pcPerioada, pcDataOra && pt. raport
|
|
Store "" To pcTitlu
|
|
pcDataOra = get_ora(2)
|
|
|
|
tcSerie = IIF(EMPTY(tcSerie), "", tcSerie)
|
|
|
|
Private pnId_gestiune, pcGestiune, pnId_articol, pcSerie
|
|
Store 0 To pnId_gestiune, pnId_articol
|
|
Store '' To pcGestiune,pcSerie
|
|
|
|
If Empty(tnIdGestiune) Or Type("tnIdGestiune")!="N"
|
|
loGest = caut_gestiune(tnTipGest, gnIdUtil)
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
pcGestiune = loGest.nume_gestiune
|
|
pnId_gestiune = loGest.id_gestiune
|
|
Else
|
|
pnId_gestiune = tnIdGestiune
|
|
pcGestiune = tcNumeGestiune
|
|
Endif
|
|
If Empty(tnIdArticol) Or Type("tnIdArticol")!="N"
|
|
loArticol = caut_articol(tnTipGest, .T.)
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
pnId_articol = loArticol.id_articol
|
|
|
|
*!* modificare 20.08.2007 ( cere seria )
|
|
pcSerie = []
|
|
ofrmSerie = Null
|
|
ofrmSerie = Createobject("frm_cere_titlu",'Serie','pcSerie')
|
|
ofrmSerie.lb_titlu_alb_b121.Caption = Alltrim(loArticol.denumire)
|
|
ofrmSerie.Show(1)
|
|
pcSerie = Alltrim(pcSerie)
|
|
*!* modificare 20.08.2007 ^
|
|
|
|
Else
|
|
pnId_articol = tnIdArticol
|
|
pcSerie = tcSerie
|
|
Endif
|
|
|
|
|
|
Private lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
Store 0 To lnAn1, lnLuna1, lnAn2, lnLuna2
|
|
|
|
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')
|
|
|
|
pcondper=""
|
|
ofrmperioada=Createobject('frm_perioada_luni')
|
|
With ofrmperioada
|
|
._textbox1.Value=lcLuna1
|
|
._textbox2.Value=lcLuna2
|
|
._optiongrup1.Value = 2
|
|
._optiongrup1.Valid()
|
|
Endwith
|
|
ofrmperioada.Show(1)
|
|
If gnButon=2
|
|
Return
|
|
Endif
|
|
|
|
plPerioada=.F.
|
|
lnPoz=At('_',pcondper)
|
|
If lnPoz>0
|
|
plPerioada=.T.
|
|
Endif
|
|
|
|
|
|
If plPerioada
|
|
lnAn1 = Val(Substr(pcondper,3,4))
|
|
lnLuna1 = Val(Substr(pcondper,1,2))
|
|
lnAn2 = Val(Substr(pcondper,10,4))
|
|
lnLuna2 = Val(Substr(pcondper,8,2))
|
|
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,8,2)+'/'+Substr(pcondper,10,4)
|
|
Else
|
|
lnAn1 = Val(Substr(pcondper,3,4))
|
|
lnLuna1 = Val(Substr(pcondper,1,2))
|
|
lnAn2 = Val(Substr(pcondper,3,4))
|
|
lnLuna2 = Val(Substr(pcondper,1,2))
|
|
|
|
lnInit = lnAn1 * 12 + lnLuna1
|
|
lnFinal = lnAn2 * 12 + lnLuna2
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4)
|
|
Endif
|
|
***-------------------------------
|
|
*!* lcSel = [{call pack_gest_rapoarte.fisa_magazie(?lnAn1, ?lnLuna1, ?lnAn2, ?lnLuna2, ?pnId_gestiune, ?pnId_articol)}]
|
|
*!* lcCursor = 'cFisa'
|
|
*!* lnSucces = goExecutor.oExecute(lcSel,lcCursor)
|
|
|
|
*!* If lnSucces < 0
|
|
*!* amessage('Call pack_gest_rapoarte.fisa_magazie' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
*!* Return
|
|
*!* Endif
|
|
***----------------------------
|
|
*------------------------------
|
|
|
|
|
|
If pnId_articol = 0
|
|
lcCond = " and id_gestiune = " + Str(pnId_gestiune)
|
|
Else
|
|
lcCond = " and id_gestiune = " + Str(pnId_gestiune) + " and id_articol = " + Str(pnId_articol) + ;
|
|
IIF(!Empty(Alltrim(Nvl(pcSerie,'')))," and serie = ?pcSerie "," and TRIM(serie) IS NULL ")
|
|
Endif
|
|
If tnTipGest = 6
|
|
lcPret = "pretv"
|
|
Else
|
|
lcPret = "pret"
|
|
Endif
|
|
lcStoc = 'crsStoc'
|
|
lcRulaje = 'crsRulaje'
|
|
|
|
If Used(lcStoc)
|
|
Use In (lcStoc)
|
|
Endif
|
|
|
|
If Used(lcRulaje)
|
|
Use In (lcRulaje)
|
|
Endif
|
|
lcCond = lcCond + gcCondSucursala
|
|
lcSqlStoc = "select id_articol,denumire,serie,"+ lcPret +" as pret,codmat,um,id_gestiune,cants,cante,cant,datain from vstoc where an = " + Str(lnAn1) + " and luna = " + Str(lnLuna1) + lcCond
|
|
lcSqlRulaje = "select cod,nnir,id_articol,denumire,serie,codmat,um,id_gestiune,cant,cante,"+ lcPret +" as pret,valoare,dataact,datain,dataout from vrul where an * 12 + luna between " + Str(lnAn1*12+lnLuna1) + " and " + Str(lnAn2*12+lnLuna2) + lcCond
|
|
lnSucces = goExecutor.oExecute(lcSqlStoc,lcStoc)
|
|
If lnSucces < 0
|
|
amessage('SELECT stoc' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
lnSucces = goExecutor.oExecute(lcSqlRulaje,lcRulaje)
|
|
If lnSucces < 0
|
|
amessage('SELECT rulaje' + Chr(13) + goExecutor.cEroare,0+16,"Eroare")
|
|
Return
|
|
Endif
|
|
Select crsStoc
|
|
Replace All denumire With Nvl(denumire,''), serie With Nvl(serie,''),codmat With Nvl(codmat,''), um With Nvl(um,''), datain With Nvl(datain,{//::})
|
|
Select crsRulaje
|
|
Replace All nnir With Nvl(nnir,0),denumire With Nvl(denumire,''), serie With Nvl(serie,''), codmat With Nvl(codmat,''), um With Nvl(um,''), datain With Nvl(datain,{//::}), dataout With Nvl(dataout,{//::}), dataact With Nvl(dataact,{//::})
|
|
|
|
|
|
Select id_articol, codmat, denumire, um, serie From crsStoc ;
|
|
UNION ;
|
|
SELECT id_articol, codmat, denumire, um, serie From crsRulaje;
|
|
INTO Cursor crsArticole;
|
|
ORDER By 2, 3
|
|
|
|
*!* modificare 28.11.2006
|
|
*!* CREATE TABLE &gcTempPath\fisa_stoc (id_articol N(20),denumire c(100),codmat c(50),um c(6),ldata d,nrdoc c(15),cantin N(12,3),;
|
|
*!* pretin N(12,3),valin N(14,2),cantout N(12,3),pretout N(12,3),valout N(14,2),cantf N(12,3),pretf N(12,3),;
|
|
*!* valf N(14,2),idf N(10))
|
|
If Used('fisa_stoc')
|
|
Use In fisa_stoc
|
|
Endif
|
|
|
|
Create Cursor fisa_stoc (id_articol N(20),denumire c(100),serie c(100),codmat c(50),um c(6),ldata d,nrdoc c(15),cantin N(12,3),;
|
|
pretin N(12,3),valin N(14,2),cantout N(12,3),pretout N(12,3),valout N(14,2),cantf N(12,3),pretf N(12,3),;
|
|
valf N(14,2),idf N(10))
|
|
*!* modificare 28.11.2006 ^
|
|
Select crsArticole
|
|
Scan
|
|
lnIdArticol = id_articol
|
|
lcDenumire = Alltrim(denumire)
|
|
lcCodMat = Alltrim(codmat)
|
|
lcUm = Alltrim(um)
|
|
lcSerie = Alltrim(serie)
|
|
*==============================
|
|
*!* modificare 28.11.2006
|
|
*!* SELECT id_articol,cants AS cantf, PRET AS pretf,cants*PRET AS valf, datain AS ldata," " AS nrdoc,;
|
|
*!* denumire,codmat,um,000000000000.000 AS cantin,000000000000.000 AS pretin,00000000000000.00 AS valin,;
|
|
*!* 000000000000.000 AS cantout,000000000000.000 AS pretout,00000000000000.000 AS valout,0000000000 AS idf;
|
|
*!* FROM crsStoc WHERE id_articol = lnIdArticol AND cants <> 0;
|
|
*!* INTO TABLE &gcTempPath\cstoc ORDER BY datain READWRITE
|
|
Select id_articol,serie,cants As cantf, Pret As pretf,cants*Pret As valf, datain As ldata," " As nrdoc,;
|
|
denumire,codmat,um,000000000000.000 As cantin,000000000000.000 As pretin,00000000000000.00 As valin,;
|
|
000000000000.000 As cantout,000000000000.000 As pretout,00000000000000.000 As valout,0000000000 As idf;
|
|
FROM crsStoc Where id_articol = lnIdArticol And cants <> 0 And Nvl(serie,'+_') = Nvl(lcSerie,'+_') ;
|
|
INTO Cursor cstoc Order By datain Readwrite
|
|
*!* modificare 28.11.2006 ^
|
|
|
|
Select cstoc
|
|
Sum cantf To lnCantf
|
|
Sum valf To lnValf
|
|
Locate For Empty(idf)
|
|
If Found()
|
|
Replace cantin With lnCantf, valin With lnValf,nrdoc With 'Stoc initial'
|
|
Replace denumire With lcDenumire, codmat With lcCodMat, um With lcUm, id_articol With lnIdArticol,serie With lcSerie
|
|
Replace All idf With 1 For Empty(idf)
|
|
Endif
|
|
|
|
If _Tally > 0
|
|
*!* modificare 28.11.2006
|
|
*!* lcDbfStoc = DBF("cstoc")
|
|
*!* SELECT fisa_stoc
|
|
*!* APPEND FROM (lcDbfStoc)
|
|
Select fisa_stoc
|
|
Append From Dbf('cstoc')
|
|
*!* modificare 28.11.2006 ^
|
|
Else
|
|
Select fisa_stoc
|
|
Append Blank
|
|
Replace cantin With lnCantf, valin With lnValf,nrdoc With 'Stoc initial'
|
|
Replace denumire With lcDenumire, codmat With lcCodMat, um With lcUm, id_articol With lnIdArticol,serie With lcSerie
|
|
Replace All idf With 1 For Empty(idf)
|
|
Endif
|
|
|
|
If Used('crulaj')
|
|
Use In crulaj
|
|
Endif
|
|
Select * From crsRulaje Where id_articol = lnIdArticol And Nvl(serie,'+_') = Nvl(lcSerie,'+_');
|
|
INTO Cursor crulaj Order By dataact, cod, nnir
|
|
|
|
Select crulaj
|
|
|
|
Scan
|
|
Scatter Name xrul
|
|
|
|
Select fisa_stoc
|
|
Calculate Max(idf) To lnMax
|
|
lnMax = lnMax + 1
|
|
|
|
Select cstoc
|
|
Replace All idf With lnMax
|
|
|
|
Do Case
|
|
Case xrul.CANT != 0
|
|
Locate For pretf = xrul.Pret
|
|
If !Found()
|
|
Select cstoc
|
|
Append Blank
|
|
Replace cantin With xrul.CANT,pretin With xrul.Pret,valin With xrul.CANT*xrul.Pret
|
|
Replace cantout With 0
|
|
Replace cantf With xrul.CANT, pretf With xrul.Pret,valf With xrul.CANT*xrul.Pret
|
|
Replace idf With lnMax,ldata With xrul.datain,nrdoc With Str(xrul.nnir)
|
|
Replace id_articol With lnIdArticol
|
|
Replace denumire With xrul.denumire, codmat With xrul.codmat, um With xrul.um, serie With xrul.serie
|
|
Else
|
|
Replace cantin With xrul.CANT,pretin With xrul.Pret,valin With xrul.CANT*xrul.Pret
|
|
Replace cantf With cantf+xrul.CANT,valf With valf+valin
|
|
Replace ldata With xrul.datain,nrdoc With Str(xrul.nnir)
|
|
Replace id_articol With lnIdArticol
|
|
Replace denumire With xrul.denumire, codmat With xrul.codmat, um With xrul.um, serie With xrul.serie
|
|
Endif
|
|
Case xrul.CANTE != 0
|
|
Select cstoc
|
|
Locate For pretf=xrul.Pret
|
|
If !Found()
|
|
Append Blank
|
|
Replace idf With lnMax
|
|
Endif
|
|
Replace cantout With xrul.CANTE,pretout With xrul.Pret,valout With xrul.CANTE*xrul.Pret
|
|
Replace cantf With cantf-xrul.CANTE,pretf With xrul.Pret,valf With valf-valout
|
|
Replace ldata With xrul.dataout,nrdoc With Str(xrul.nnir)
|
|
Replace id_articol With lnIdArticol
|
|
Replace denumire With xrul.denumire, codmat With xrul.codmat, um With xrul.um, serie With xrul.serie
|
|
Endcase
|
|
Select fisa_stoc
|
|
*!* APPEND FROM &gcTempPath\cstoc
|
|
Append From Dbf('cstoc')
|
|
Select cstoc
|
|
Delete All For cantf=0
|
|
Replace All cantin With 0, cantout With 0
|
|
Release xrul
|
|
Select crulaj
|
|
Endscan &&crulaj
|
|
Endscan && crsArticole
|
|
*=======================================================================================================
|
|
pcTitlu = "FISA DE MAGAZIE"
|
|
Select fisa_stoc
|
|
replace ALL nrdoc WITH '' FOR cantin=0 AND cantout=0 AND alltrim(nrdoc)<>'Stoc initial'
|
|
If Reccount('fisa_stoc')>0
|
|
*Keyboard '{CTRL+F10}'
|
|
*Report Form fisa_magazie_FIFO To Printer Prompt Preview
|
|
goExport.export2frx([fisa_stoc],[fisa_magazie_FIFO],.T., , , , , .T.)
|
|
Else
|
|
amessagebox("Nu exista inregistrari pentru listare!",0+48,"Atentie")
|
|
Endif
|
|
|
|
If Used('crsstoc')
|
|
Use In crsStoc
|
|
Endif
|
|
|
|
If Used('crsrulaje')
|
|
Use In crsRulaje
|
|
Endif
|
|
|
|
If Used('crsarticole')
|
|
Use In crsArticole
|
|
Endif
|
|
|
|
If Used('cstoc')
|
|
Use In cstoc
|
|
Endif
|
|
|
|
If Used('crulaj')
|
|
Use In crulaj
|
|
Endif
|
|
|
|
If Used("fisa_stoc")
|
|
Use In fisa_stoc
|
|
Endif
|
|
|
|
Endproc && fisa_magazie_FIFO
|
|
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure fisa_ob_inventar_resp
|
|
Parameters tlExcel
|
|
&& tlToate - se genereaza raportul pt. toate obiectele de inventar
|
|
|
|
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)
|
|
***-------------------------------
|
|
lcSel = [{call pack_gest_rapoarte.fisa_ob_inventar_resp(?pdDataI, ?pdDataF, ?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
|
|
***-------------------------------
|
|
pcTitlu = "FISA DE EVIDENTA A OBIECTELOR DE INVENTAR IN FOLOSINTA"
|
|
|
|
If tlExcel
|
|
goExport.export2xls([cFisa])
|
|
*!* Do export_xls With "cFisa"
|
|
Else
|
|
goExport.export2frx([cFisa],[fisa_obi_resp])
|
|
*!* Select cFisa
|
|
*!* Report Form fisa_obi_resp To Printer Prompt Preview
|
|
Endif
|
|
If Used("cFisa")
|
|
Use In cFisa
|
|
Endif
|
|
|
|
Endproc && fisa_ob_inventar_resp
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure fisa_ob_inventar_resp_stoc
|
|
Parameters tlExcel
|
|
&& tlToate - se genereaza raportul pt. toate obiectele de inventar
|
|
|
|
Private pcTitlu &&, pcDataOra
|
|
Store "" To pcTitlu &&, pcDataOra
|
|
Local lcOrder, lcOrderColumn, loColumnSort
|
|
lcOrder = ""
|
|
lcOrderColumn = ""
|
|
|
|
|
|
Private pnId_responsabil
|
|
Store 0 To pnId_responsabil
|
|
lcTitlu = [CANTITATI CUMULATE]
|
|
pcTitlu = lcTitlu && ceretitlu_rap([Titlul raportului],lcTitlu)
|
|
*!* pcDataOra = get_ora(2)
|
|
pcGrupGest = [ALLTRIM(nresp) + ', NR. MATRICOL: ' + ALLTRIM(IIF(NVL(marca,0)=0,'',STR(NVL(marca,0))))]
|
|
pcGrupCont = [EOF()]
|
|
pcGrupAcont = [EOF()]
|
|
pcHeaderGrup = [Responsabil ]
|
|
lcOrder = "nresp,denumire,codmat"
|
|
lcSql = []
|
|
N=0
|
|
lcKeepTitle=""
|
|
gnButon=1
|
|
Do While gnButon#2
|
|
N=N+1
|
|
loResp = caut_responsabil(.T.)
|
|
If gnButon=2
|
|
Exit
|
|
Endif
|
|
pnId_responsabil = loResp.id_responsabil
|
|
If(N>1)
|
|
pcTitlu =lcKeepTitle
|
|
Else
|
|
pcTitlu = ceretitlu_rap([Titlul raportului],[SUBINVENTAR LA ]+Dtoc(Date()))
|
|
lcKeepTitle=pcTitlu
|
|
Endif
|
|
|
|
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
|
|
***-------------------------------
|
|
|
|
If tlExcel
|
|
goExport.export2xls([cFisa])
|
|
*!* Do export_xls With "cFisa"
|
|
Else
|
|
goExport.export2frx([cFisa],[rap_stocachi_grup2])
|
|
*!* Select cFisa
|
|
*!* Report Format rap_stocachi_grup2.FRX To Printer Prompt Noconsole Preview
|
|
Endif
|
|
Enddo
|
|
|
|
If Used('cFisa')
|
|
Use In cFisa
|
|
Endif
|
|
|
|
Endproc && fisa_ob_inventar_resp_stoc
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure necesar_echipamente
|
|
|
|
Private pdData
|
|
Store Date() To pdData
|
|
|
|
Private pocond,pcschema1,pcselect1,pcfiltru1,pcorder1 &&Conditii din nomenclator
|
|
Store '' To pocond,pcschema1,pcselect1,pcfiltru1,pcorder1
|
|
|
|
pcschema1 = ['']
|
|
pcselect1 = ['select id_conditie,denumire,conditie from sal_vnom_cond where 1=1']
|
|
lcCursor = [sCond]
|
|
pcorder1 = [denumire]
|
|
pcfiltru1 = [2=2]
|
|
llAfiseaza = .T.
|
|
gencursor('pocond',lcCursor,pcselect1,pcfiltru1,pcschema1,pcorder1,llAfiseaza)
|
|
pocond.ca_baza1.afisare()
|
|
|
|
Select *, 1 As ales From sCond Into Cursor v_conditii Readwrite
|
|
Select v_conditii
|
|
|
|
***-----------
|
|
Private poper, pcschema3, pcselect3, pcfiltru3, pcorder3 &&Persoane
|
|
Store '' To poper,pcschema3,pcselect3,pcfiltru3,pcorder3
|
|
pcschema3 = ['']
|
|
pcselect3 = ['select s.id_part,s.marca,s.nume,s.prenume, s.meserie, s.formatia, 0 as ales from sal_vstat s '+] + ;
|
|
[' where 1=2']
|
|
pcfiltru3 = [1=2]
|
|
pcorder3 = [nume,prenume]
|
|
llAfiseaza = .T.
|
|
|
|
gencursor('poper','v_pers',pcselect3,pcfiltru3,pcschema3,pcorder3,llAfiseaza)
|
|
poper.ca_baza1.afisare()
|
|
|
|
lone = Createobject('frm_necesar_echipamente')
|
|
lone.Show(1)
|
|
|
|
|
|
Endproc && necesar_echipamente
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
|
|
*!* Procedure raport_rulaj
|
|
*!* Lparameters toHash
|
|
|
|
*!* If Type('toHash') <> 'O'
|
|
*!* toHash = GetHash()
|
|
*!* Endif
|
|
|
|
*!* Private poFiltru
|
|
*!* poFiltru = Createobject("custom")
|
|
|
|
*!* With poFiltru
|
|
*!* .AddProperty("cSql","")
|
|
*!* .AddProperty("nrord","")
|
|
*!* .AddProperty("id_lucrare",0)
|
|
*!* .AddProperty("nume_gestiune","")
|
|
*!* .AddProperty("id_gestiune",0)
|
|
*!* .AddProperty("sectie","")
|
|
*!* .AddProperty("id_sectie",0)
|
|
*!* .AddProperty("nresp","")
|
|
*!* .AddProperty("id_responsabil",0)
|
|
*!* Endwith
|
|
|
|
*!* *!* loRap = Createobject("frm_date_rapoarte_rulaje", toHash)
|
|
*!* loRap = Createobject("frm_date_rapoarte_rulaje")
|
|
*!* loRap.Show(1)
|
|
|
|
*!* Endproc && raport_rulaj
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
*!* Procedure consum_lucrari_articole
|
|
|
|
*!* Local loHash
|
|
*!* loHash = GetHash()
|
|
*!* With loHash
|
|
*!* .SetValue("cListaCampuri", "lucrare,articol,serie,cante,valoutach")
|
|
*!* .SetValue("cListaOrdonare", "1,2,3")
|
|
*!* .SetValue("cListaGrupare", "1,2,3")
|
|
*!* .SetValue("cTipRulaj", "IESIRI")
|
|
*!* .SetValue("cTitlu", "Consum materiale pe lucrari/articole")
|
|
*!* .SetValue("cRaport", "rap_rul_consum_lucrari_articole")
|
|
*!* .SetValue("lReadOnly", .T.)
|
|
*!* Endwith
|
|
|
|
*!* Do raport_rulaj With loHash && "lucrare,articol,cante,valoutach", "1,2", "1,2", "IESIRI"
|
|
*!* Endproc && consum_lucrari_articole
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
*!* Procedure centralizator_consum_lucrari
|
|
|
|
*!* Local loHash
|
|
*!* loHash = GetHash()
|
|
*!* With loHash
|
|
*!* .SetValue("cListaCampuri", "cont,lucrare,valoutach")
|
|
*!* .SetValue("cListaOrdonare", "1,2")
|
|
*!* .SetValue("cListaGrupare", "1,2")
|
|
*!* .SetValue("cTipRulaj", "IESIRI")
|
|
*!* .SetValue("cTitlu", "Centralizator consum pe lucrari")
|
|
*!* .SetValue("cRaport", "rap_rul_centralizator_consum_lucrari")
|
|
*!* .SetValue("lReadOnly", .T.)
|
|
*!* Endwith
|
|
|
|
*!* Do raport_rulaj With loHash && "lucrare,articol,cante,valoutach", "1,2", "1,2", "IESIRI"
|
|
|
|
*!* Endproc && centralizator_consum_lucrari
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
Procedure rap_compar_stoc_bal
|
|
|
|
Private pcLunaI, pcLunaF
|
|
pcLunaI = Padl(gnLuna,2,'0') + Alltrim(Str(gnAn))
|
|
pcLunaF = Padl(gnLuna,2,'0') + Alltrim(Str(gnAn))
|
|
|
|
locsb = Createobject('frm_compar_stoc_bal')
|
|
locsb.Show(1)
|
|
|
|
Endproc && rap_compar_stoc_bal
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
PROCEDURE fisa_magazie_FIFO_valuta
|
|
Lparameters tnTipGest, tnIdGestiune, tcNumeGestiune, tnIdArticol, tcSerie,tnIdValuta,tcValuta
|
|
|
|
Private pcTitlu, pcPerioada, pcDataOra && pt. raport
|
|
Store "" To pcTitlu
|
|
|
|
|
|
pcDataOra = get_ora(2)
|
|
|
|
tcSerie = IIF(EMPTY(tcSerie), "", tcSerie)
|
|
|
|
Private pnId_gestiune, pcGestiune, pnId_articol, pcSerie,pnIdValuta,pcValuta
|
|
Store 0 To pnId_gestiune, pnId_articol,pnIdValuta
|
|
Store '' To pcGestiune,pcSerie,pcValuta
|
|
|
|
If Empty(tnIdGestiune) Or Type("tnIdGestiune")!="N"
|
|
loGest = caut_gestiune(tnTipGest, gnIdUtil)
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
pcGestiune = loGest.nume_gestiune
|
|
pnId_gestiune = loGest.id_gestiune
|
|
pcNumeGestiune = Upper(Alltrim(loGest.nume_gestiune))
|
|
Else
|
|
pnId_gestiune = tnIdGestiune
|
|
pcGestiune = tcNumeGestiune
|
|
pcNumeGestiune = tcNumeGestiune
|
|
Endif
|
|
If Empty(tnIdArticol) Or Type("tnIdArticol")!="N"
|
|
loArticol = caut_articol(tnTipGest, .T.)
|
|
If buton = 2
|
|
Return
|
|
Endif
|
|
pnId_articol = loArticol.id_articol
|
|
|
|
*!* modificare 20.08.2007 ( cere seria )
|
|
pcSerie = []
|
|
ofrmSerie = Null
|
|
ofrmSerie = Createobject("frm_cere_titlu",'Serie','pcSerie')
|
|
ofrmSerie.lb_titlu_alb_b121.Caption = Alltrim(loArticol.denumire)
|
|
ofrmSerie.Show(1)
|
|
pcSerie = Alltrim(pcSerie)
|
|
*!* modificare 20.08.2007 ^
|
|
pcDenumire = Upper(Alltrim(loArticol.denumire))
|
|
pcUm = Upper(Alltrim(loArticol.um))
|
|
pcCodMaterial = Upper(Alltrim(loArticol.codmat))
|
|
Else
|
|
pnId_articol = tnIdArticol
|
|
pcSerie = tcSerie
|
|
Endif
|
|
If Empty(tnIdValuta) Or Type("tnIdValuta")!="N"
|
|
loValuta = caut_valuta(.f.,.f., .T.)
|
|
If buton = 2 Or (Empty(loValuta.id_valuta) And Empty(loValuta.nume_val))
|
|
Return
|
|
Endif
|
|
pnIdValuta = loValuta.id_valuta
|
|
pcValuta =ALLTRIM(loValuta.nume_val)
|
|
|
|
Else
|
|
pnIdValuta = tnIdValuta
|
|
pcValuta = TcValuta
|
|
Endif
|
|
*!* Private pnIdArticol,pcDenumire,pnId_gestiune,pcNumeGestiune,pcSerie,pcUm,pcCodMaterial,pcTitlu, pcPerioada, pcDataOra,pnIdValuta
|
|
*!* Store '' To pcTitlu,pcNumeGestiune,pcSerie,pcUm,pcCodMaterial,pcDataOra
|
|
|
|
*!* If Used('crstemp')
|
|
*!* Use In crstemp
|
|
*!* Endif
|
|
|
|
*!* Select (lcCursor) && crsrul
|
|
*!* pnIdArticol = id_articol
|
|
*!* pnIdGestiune = id_gestiune
|
|
*!* pcDenumire = Upper(Alltrim(denumire))
|
|
*!* pcUm = Upper(Alltrim(um))
|
|
*!* pcCodMaterial = Upper(Alltrim(codmat))
|
|
*!* pcSerie = Upper(Alltrim(serie))
|
|
*!* pcNumeGestiune = Upper(Alltrim(nume_gestiune))
|
|
*!* pnIdValuta = Nvl(id_valuta,0)
|
|
|
|
*!* pcTitlu = [FISA MAGAZIE ( CU PRETURI IN VALUTA )]
|
|
*!* ofrmTitlu = Createobject("frm_cere_titlu",'Titlu','pcTitlu')
|
|
*!* ofrmTitlu.Show(1)
|
|
*!* pcTitlu = Alltrim(pcTitlu)
|
|
*!* Release ofrmTitlu
|
|
|
|
|
|
*!* perioada raport
|
|
Private pnAnI, pnLunaI, pnAnLunaI, pnAnLunaF
|
|
Store 0 To pnAnI, pnLunaI, pnAnLunaI, pnAnLunaF
|
|
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')
|
|
|
|
pcondper=""
|
|
ofrmperioada=Createobject('frm_perioada_luni')
|
|
With ofrmperioada
|
|
._textbox1.Value=lcLuna1
|
|
._textbox2.Value=lcLuna2
|
|
._optiongrup1.Value = 2
|
|
._optiongrup1.Valid()
|
|
Endwith
|
|
ofrmperioada.Show(1)
|
|
If gnButon=2
|
|
Return
|
|
Endif
|
|
pcTitlu = [FISA MAGAZIE ( CU PRETURI IN ]+pcValuta + [ )]
|
|
ofrmTitlu = Createobject("frm_cere_titlu",'Titlu','pcTitlu')
|
|
ofrmTitlu.Show(1)
|
|
pcTitlu = Alltrim(pcTitlu)
|
|
Release ofrmTitlu
|
|
|
|
plPerioada=.F.
|
|
lnPoz=At('_',pcondper)
|
|
If lnPoz>0
|
|
plPerioada=.T.
|
|
Endif
|
|
|
|
|
|
If plPerioada
|
|
pnAnI = Val(Substr(pcondper,3,4))
|
|
pnLunaI = Val(Substr(pcondper,1,2))
|
|
pnAnF = Val(Substr(pcondper,10,4))
|
|
pnLunaF = Val(Substr(pcondper,8,2))
|
|
|
|
pnAnLunaI = pnAnI * 12 + pnLunaI
|
|
pnAnLunaF = pnAnF * 12 + pnLunaF
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,8,2)+'/'+Substr(pcondper,10,4)
|
|
Else
|
|
pnAnI = Val(Substr(pcondper,3,4))
|
|
pnLunaI = Val(Substr(pcondper,1,2))
|
|
|
|
pnAnLunaI = pnAnI * 12 + pnLunaI
|
|
pnAnLunaF = pnAnLunaI
|
|
pcPerioada = Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4) + ' - ' + Substr(pcondper,1,2)+'/'+Substr(pcondper,3,4)
|
|
Endif
|
|
|
|
*!* lcSql = [select a.dataact,a.nnir,a.pret,a.pretd,a.nume_valuta_a,a.cant,a.pretv,a.pretdv,a.nume_valuta_v,] + ;
|
|
*!* [a.cante,sum(nvl(a.cant, 0) - nvl(a.cante, 0)) over(order by a.dataact,a.dataora) as cants ] + ;
|
|
*!* [from (select last_day(to_date(a.an || a.luna, 'YYYYMM')) as dataact, ] + ;
|
|
*!* [null as nnir,a.pret,a.pretd,decode(b.moneda_nationala, 0, b.nume_val, null) as nume_valuta_a,] + ;
|
|
*!* [a.cants + a.cant - a.cante as cant,null as pretv,0 as pretdv,null as nume_valuta_v,null as cante,null as dataora ] + ;
|
|
*!* [from ] + gcS + [.stoc a ] + ;
|
|
*!* [left join ] + gcS + [.nom_valute b on a.id_valuta = b.id_valuta ] +;
|
|
*!* [where a.id_articol = ?pnId_Articol and NVL(a.id_valuta,0) = ?pnIdValuta and a.luna = ?pnLunaI and a.an = ?pnAnI ] + ;
|
|
*!* [and NVL(a.serie,'+_') = NVL(?pcSerie,'+_') and a.id_gestiune = ?pnId_gestiune ] + ;
|
|
*!* STRTRAN(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
*!* [union all ] + ;
|
|
*!* [select a.dataact,a.nnir,a.pret,] + ;
|
|
*!* [a.pretd,decode(d.moneda_nationala, 0, d.nume_val, null) as nume_valuta_a,] + ;
|
|
*!* [decode(a.cante, 0, a.cant, null) as cant,decode(a.cant, 0, a.pretv, null) as pretv,] + ;
|
|
*!* [decode(e.moneda_nationala,0,decode(c.pret_cu_tva,0,c.pret,1,round(c.pret / c.proc_tvav,] + ;
|
|
*!* [pack_sesiune.getoptiunefirma('PVAL'))),0) as pretdv,] + ;
|
|
*!* [decode(e.moneda_nationala, 0, e.nume_val, null) as nume_valuta_v,decode(a.cant, 0, a.cante, null) as cante,a.dataora ] + ;
|
|
*!* [from ] + gcS + [.rul a ] + ;
|
|
*!* [left join ] + gcS + [.vanzari b on a.cod = b.cod and b.sters = 0 and NVL(a.id_sucursala,-99) = NVL(b.id_sucursala,-99) ] + ;
|
|
*!* [left join ] + gcS + [.vanzari_Detalii c on a.id_articol = c.id_articol ] + ;
|
|
*!* [and a.id_gestiune = c.id_gestiune and a.cont = c.cont and nvl(a.serie, '+_') = nvl(c.serie, '+_') ] + ;
|
|
*!* [and b.id_vanzare = c.id_vanzare ] + ;
|
|
*!* [left join ] + gcS + [.nom_valute d on a.id_valuta = d.id_valuta ] + ;
|
|
*!* [left join ] + gcS + [.nom_valute e on c.id_valuta = e.id_valuta ] + ;
|
|
*!* [where a.id_articol = ?pnId_Articol and NVL(a.id_valuta,0) = ?pnIdValuta and a.sters = 0 ] + ;
|
|
*!* [and NVL(a.serie,'+_') = NVL(?pcSerie,'+_') and a.id_gestiune = ?pnId_gestiune ] + ;
|
|
*!* Strtran(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
*!* [and a.id_tip_rulaj <> 3 and a.luna + a.an * 12 between ?pnAnLunaI and ?pnAnLunaF order by 1) a ]
|
|
|
|
lcSql = [select dataact,nnir,pret,pretd,nume_valuta_a,cant,pretv, pretdv, nume_valuta_v, cante, cants,dataora,] + ;
|
|
[sum(case when dataora is null then 0 when cants <> 0 Or ((cant Is Not Null Or cante Is Not Null) And cants = 0) then 1 else 0 end)] + ;
|
|
[ over(partition by dataact, dataora order by pretd) as ordine from ] + ;
|
|
[(select dataact,nnir,pret,pretd,nume_valuta_a,cant,pretv, pretdv,nume_valuta_v,cante,dataora,] + ;
|
|
[sum(nvl(cant, 0) - nvl(cante, 0)) over(partition by pretd order by dataact, dataora) as cants from ] +;
|
|
[(select last_day(to_date(a.an || a.luna, 'YYYYMM')) as dataact,null as nnir,] +;
|
|
[a.pret,a.pretd,decode(b.moneda_nationala, 0, b.nume_val, null) as nume_valuta_a, a.cants + a.cant - a.cante as cant,]+;
|
|
[null as pretv,null as pretdv, null as nume_valuta_v, null as cante, null as dataora ]+;
|
|
[from ] + gcS + [.stoc a ] + ;
|
|
[left join ] + gcS + [.nom_valute b on a.id_valuta = b.id_valuta ] +;
|
|
[where a.id_articol = ?pnId_Articol and NVL(a.id_valuta,0) = ?pnIdValuta and a.luna + a.an * 12 = ?pnAnLunaI-1 ] + ;
|
|
[and NVL(a.serie,'+_') = NVL(?pcSerie,'+_') and a.id_gestiune = ?pnId_gestiune ] + ;
|
|
STRTRAN(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
[ union all ] + ;
|
|
[(select a.dataact,a.nnir,f.pret, f.pretd,decode(d.moneda_nationala,0,d.nume_val,null) as nume_valuta_a,]+;
|
|
[decode(a.pretd,f.pretd,decode(a.cante, 0, a.cant, null),null) as cant,]+;
|
|
[decode(a.pretd,f.pretd,decode(a.cant, 0, a.pretv, null),null) as pretv,] +;
|
|
[decode(a.pretd,f.pretd,decode(e.moneda_nationala,0,decode(c.pret_cu_tva, 0,c.pret, 1,] +;
|
|
[round(c.pret / c.proc_tvav,pack_sesiune.getoptiunefirma('PVAL'))), null),null) as pretdv,] +;
|
|
[decode(a.pretd, f.pretd,decode(e.moneda_nationala,0, e.nume_val,null),null) as nume_valuta_v,] +;
|
|
[decode(a.pretd,f.pretd,decode(a.cant, 0, a.cante, null),null) as cante,a.dataora ] +;
|
|
[from ] + gcS + [.rul a ] +;
|
|
[left join ] + gcS + [.vanzari b on a.cod = b.cod and b.sters = 0 and NVL(a.id_sucursala,-99)=NVL(b.id_sucursala,-99) ] +;
|
|
[left join ] + gcS + [.vanzari_Detalii c on a.id_articol = c.id_articol and a.id_gestiune = c.id_gestiune and a.cont = c.cont and nvl(a.serie,'+_') = nvl(c.serie,'+_') and b.id_vanzare = c.id_vanzare ] +;
|
|
[left join ] + gcS + [.nom_valute d on a.id_valuta = d.id_valuta ] +;
|
|
[left join ] + gcS + [.nom_valute e on c.id_valuta = e.id_valuta ] +;
|
|
[left join (select a.pret, a.pretd, a.id_gestiune ] +;
|
|
[from ] + gcS + [.stoc a ] +;
|
|
[where a.id_articol = ?pnId_Articol and NVL(a.id_valuta, 0) = ?pnIdValuta and a.luna + a.an * 12 = ?pnAnLunaI-1 and NVL(a.serie, '+_') = NVL(?pcSerie, '+_') and a.id_gestiune = ?pnId_gestiune ] +;
|
|
STRTRAN(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
[ union select a.Pret, a.pretd, a.id_gestiune from ] + gcS + [.rul a ] + ;
|
|
[Where a.id_articol = ?pnId_Articol ] +;
|
|
[And Nvl(a.id_valuta, 0) = ?pnIdValuta ] +;
|
|
[And a.sters = 0 ] +;
|
|
[And Nvl(a.serie, '+_') = ] +;
|
|
[Nvl(?pcSerie, '+_') ] +;
|
|
[And a.id_gestiune = ?pnId_gestiune ] +;
|
|
STRTRAN(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
[ And a.id_tip_rulaj <> 3 And a.luna + a.an * 12 Between ?pnAnLunaI And ?pnAnLunaF) F On a.id_gestiune = F.id_gestiune ] +;
|
|
[Where a.id_articol = ?pnId_Articol And Nvl(a.id_valuta, 0) = ?pnIdValuta And a.sters = 0 ] +;
|
|
[And Nvl(a.serie, '+_') = Nvl(?pcSerie, '+_') And a.id_gestiune = ?pnId_gestiune ] +;
|
|
STRTRAN(gcCondSucursala,[id_sucursala],[a.id_sucursala]) + ;
|
|
[ And a.id_tip_rulaj <> 3 And a.luna + a.an * 12 Between ?pnAnLunaI And ?pnAnLunaF))) ] +;
|
|
[Where cants <> 0 Or ((cant Is Not Null Or cante Is Not Null) And cants = 0) ] +;
|
|
[Order By dataact, dataora, pretd ]
|
|
|
|
lnSucces = goExecutor.oExecute(lcSql,[crstemp])
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare,16,"Eroare")
|
|
Else
|
|
If Reccount('crstemp')>0
|
|
pcDataOra = get_ora(2)
|
|
*Keyboard '{CTRL+F10}'
|
|
Select crstemp
|
|
*Report Form fisa_magazie_fifo_val To Printer Prompt Preview
|
|
goExport.export2frx([crstemp],[fisa_magazie_fifo_val],.F., , , , , .T.)
|
|
Else
|
|
amessagebox("Nu exista inregistrari pentru perioada selectata!",0+48,"Atentie")
|
|
Endif
|
|
Endif
|
|
|
|
If Used('crstemp')
|
|
Use In crstemp
|
|
Endif
|
|
ENDPROC
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|
|
PROCEDURE rap_stocuri_pe_vechimi
|
|
PRIVATE pcCont,pcGestiune,pnid_gestiune,ofrmopt,pnOptiune,pnButon, pdDataReferinta
|
|
STORE '' TO pcCont,pcGestiune
|
|
STORE 0 TO pnid_gestiune
|
|
pdDataReferinta = DATE()
|
|
LOCAL lcFiltruInitial,lcTitlu,lcIntrebare,lnNrOptiuni,lcSql
|
|
|
|
pofrmaleg = CREATEOBJECT('frm_cerere_cont_gestiune')
|
|
pofrmaleg.show(1)
|
|
IF gnButon = 2
|
|
RETURN
|
|
ENDIF
|
|
*!* modificare ROAGEST v 2.0.103
|
|
*!* pcTitlu = ceretitlu_rap([Titlul raportului],[RAPORT STOCURI PE VECHIMI LA ]+Dtoc(Date()))
|
|
*!* modificare ROAGEST v 2.0.103 ^
|
|
|
|
lcFiltruInitial = [a.an=]+ Alltrim(Str(gnAn))+[ and a.luna=]+ Alltrim(Str(gnLuna))+[ ]+;
|
|
Strtran(gcCondSucursala,[id_sucursala],[a.id_sucursala])
|
|
|
|
IF !EMPTY(pcCont) AND !ISNULL(pcCont)
|
|
lcFiltruInitial = lcFiltruInitial + [ and a.cont = ']+ALLTRIM(pcCont)+[']
|
|
ENDIF
|
|
|
|
IF !EMPTY(pnid_gestiune) AND !ISNULL(pnid_gestiune)
|
|
lcFiltruInitial = lcFiltruInitial + [ and id_gestiune = ]+ALLTRIM(STR(pnid_gestiune))
|
|
ENDIF
|
|
|
|
lcSql = [select a.ID_ARTICOL,a.DATAIN,a.DENUMIRE,a.NUME_GESTIUNE,a.CONT,a.pret,a.CANTS+a.cant-a.cante as stoc,a.codmat,a.datain,]+;
|
|
[ NVL(trunc(last_day(to_date('] + DTOS(m.pdDataReferinta) + [','YYYYMMDD')))-trunc(a.DATAIN),400) as vechime ]+;
|
|
[ from vstoc a where ]+lcFiltruInitial +[ order by a.NUME_GESTIUNE,a.CONT,a.denumire]
|
|
lnSucces = goExecutor.oExecute(lcSql,[crsvechimestoc])
|
|
If lnSucces < 0
|
|
amessagebox(goExecutor.cEroare,16,"Eroare")
|
|
Else
|
|
If Reccount('crsvechimestoc')>0
|
|
pnOptiune=1
|
|
pnButon=1
|
|
lcTitlu="STOCURI PE VECHIMI"
|
|
lcIntrebare=" Alegeti modul de vizualizare a datelor :"
|
|
lnNrOptiuni=2
|
|
ofrmopt=Createobject("frm_optiune",lcTitlu,lcIntrebare,lnNrOptiuni)
|
|
ofrmopt.ogOptiuni.option1.Caption="Listare"
|
|
ofrmopt.ogOptiuni.option2.Caption="Export in Excel"
|
|
ofrmopt.Show(1)
|
|
|
|
*!* modificare ROAGEST v 2.0.103
|
|
IF pnButon=2
|
|
RETURN
|
|
ENDIF
|
|
*!* pcDataOra = get_ora(2)
|
|
*!* Select crsvechimestoc
|
|
IF pnOptiune=1
|
|
PRIVATE pcTitlu
|
|
*!* pcTitlu = ceretitlu_rap([Titlul raportului],[RAPORT STOCURI PE VECHIMI LA ]+Dtoc(Date()))
|
|
*!* Keyboard '{CTRL+F10}'
|
|
*!* Report Form rap_vechime_stocuri To Printer Prompt Preview
|
|
pcTitlu = [RAPORT STOCURI PE VECHIMI LA ]+DTOC(m.pdDataReferinta)
|
|
goExport.export2frx([crsvechimestoc],[rap_vechime_stocuri],.T.)
|
|
ELSE
|
|
SELECT nume_gestiune,cont,denumire,codmat,TTOD(datain) as datain,ROUND(pret,gnPPRET) as pret,ROUND(iif(vechime<31,stoc,0),gnPCANT) as cant_1_30,ROUND(iif(vechime<31,stoc,0)*pret,gnPA) as val_1_30,ROUND(iif(vechime>=31 and vechime<61,stoc,0),gnPCANT) as cant_31_60, ;
|
|
ROUND(iif(vechime>=31 and vechime<61,stoc,0)*pret,gnPA) as val_31_60,ROUND(iif(vechime>=61 and vechime<91,stoc,0),gnPCANT) as cant_61_90,ROUND(iif(vechime>=61 and vechime<91,stoc,0)*pret,gnPA) as val_61_90, ;
|
|
ROUND(iif(vechime>=91 and vechime<365,stoc,0),gnPCANT) as cant_91_1an,ROUND(iif(vechime>=91 and vechime<365,stoc,0),gnPA) as val_91_1an,ROUND(iif(vechime>=365,stoc,0),gnPCANT) as cant_Peste_1an, ;
|
|
ROUND(iif(vechime>=365,stoc,0)*pret,gnPA) as val_Peste_1an from crsvechimestoc ORDER BY nume_gestiune, cont, denumire into cursor crsvechimestocxls
|
|
goExport.export2xls([crsvechimestocxls])
|
|
ENDIF
|
|
Else
|
|
amessagebox("Nu exista inregistrari pentru perioada selectata!",0+48,"Atentie")
|
|
ENDIF
|
|
|
|
ENDIF
|
|
IF USED('crsvechimestoc')
|
|
USE IN crsvechimestoc
|
|
ENDIF
|
|
IF USED('crsvechimestocxls')
|
|
USE IN crsvechimestocxls
|
|
ENDIF
|
|
RELEASE pofrmaleg,ofrmopt
|
|
*!* modificare ROAGEST v 2.0.103 ^
|
|
|
|
ENDPROC
|
|
|
|
***-----------------------------------------------------------------------------------------------------------
|