Import initial din SVN ROAAUTO/Trunk @HEAD
This commit is contained in:
323
COMUN/programe/orap_comenzi.prg
Normal file
323
COMUN/programe/orap_comenzi.prg
Normal file
@@ -0,0 +1,323 @@
|
||||
***************************************************************************************************************
|
||||
Procedure rap_marfa_comenzi_facturate_partial
|
||||
Private pcDataOra
|
||||
lcSql = [select * from ] + gcS + [.com_vrap_marfa_nelivrata]
|
||||
lcCursor = [crsraport]
|
||||
lnSucces = goExecutor.oExecute(lcSql, lcCursor)
|
||||
If lnSucces < 0
|
||||
amessagebox(goExecutor.cEroare, 0 + 48, "Eroare")
|
||||
Return
|
||||
Endif
|
||||
|
||||
*!* modificare v 2.0.11
|
||||
*!* If Reccount('crsraport')>0
|
||||
*!* pcDataOra=get_ora(2)
|
||||
*!* Keyboard "{ctrl+f10}"
|
||||
*!* Select crsraport
|
||||
*!* Report Form rap_marfa_nelivrata To Printer Prompt Preview
|
||||
*!* Else
|
||||
*!* amessagebox("Nu exista date pentru listare!",0+64,"Listare")
|
||||
*!* Endif
|
||||
goExport.export2frx(lcCursor, [rap_marfa_nelivrata])
|
||||
*!* modificare v 2.0.11 ^
|
||||
If Used(lcCursor)
|
||||
Use In (lcCursor)
|
||||
Endif
|
||||
Endproc && rap_marfa_comenzi_facturate_partial
|
||||
***************************************************************************************************************
|
||||
Procedure rap_vanzari_perioada
|
||||
Local lnOptiune
|
||||
lnOptiune = xmenu("\<Generare raport vanzari;\<Vizualizare raport vanzari")
|
||||
Do Case
|
||||
Case lnOptiune = 1 && generare tabel comenzi bazate pe vanzari
|
||||
genereaza_rap_vanz_per()
|
||||
Case lnOptiune = 2 && vizualizare tabel comenzi bazate pe vanzari
|
||||
viz_rap_vanz_per()
|
||||
Endcase
|
||||
ENDPROC
|
||||
|
||||
PROCEDURE sterg_rap_vanz_per
|
||||
LPARAMETERS tnIdComRapVanz
|
||||
|
||||
LOCAL llSucces
|
||||
PRIVATE pnIdComRapVanz
|
||||
IF !EMPTY(tnIdComRapVanz) AND TYPE('tnIdComRapVanz') = 'N'
|
||||
pnIdComRapVanz = m.tnIdComRapVanz
|
||||
ENDIF
|
||||
|
||||
lcSql = [begin pack_comenzi.raport_proc_vanzari_sterge(?pnIdComRapVanz); end;]
|
||||
llSucces = goExecutor.oExecuta(lcSql)
|
||||
|
||||
RETURN llSucces
|
||||
ENDPROC && sterg_rap_vanz_per
|
||||
|
||||
****************************************
|
||||
* Afiseaza centralizatorul de rapoarte bazate pe vanzari si se alege un raport - ulterior se vizualizeaza/editeaza
|
||||
* Intoarce id-ul raportului ales - pentru folosirea in (re)vizualizarea raportului
|
||||
****************************************
|
||||
Function viz_rap_vanz_per
|
||||
|
||||
Local loFrm As "frm_rap_vanz_centr"
|
||||
Local lcCursor, lcSql, lnIdComRapVanz, lnSucces
|
||||
|
||||
lnIdComRapVanz = 0
|
||||
|
||||
lcSql = [{call pack_comenzi.centralizator_rapoarte(?gnLuna, ?gnAn, ?gnId_sectie)}]
|
||||
lcCursor = [crsrapoarte]
|
||||
lnSucces = goExecutor.oExecute(lcSql, lcCursor)
|
||||
If lnSucces < 0
|
||||
amessagebox(goExecutor.cEroare, 0 + 48, "Eroare")
|
||||
Else
|
||||
If Reccount("crsrapoarte") > 0
|
||||
loFrm = Createobject("frm_rap_vanz_centr")
|
||||
loFrm.Show(1)
|
||||
If gnButon = 1
|
||||
lnIdComRapVanz = crsrapoarte.id_comrapvanz
|
||||
Endif
|
||||
Else
|
||||
amessagebox("Nu exista rapoarte in luna curenta!", 48, "Atentie")
|
||||
Endif
|
||||
Endif
|
||||
Use In (Select(lcCursor))
|
||||
Return m.lnIdComRapVanz
|
||||
Endfunc && viz_rap_vanz_per
|
||||
|
||||
***************************************************************************************************************
|
||||
Procedure genereaza_rap_vanz_per
|
||||
Lparameters tnIdComRapVanz, ttDataI, ttDataS
|
||||
* tnIdComRapVanz: optional = daca este completat se modifica raportul deja generat, altfel se genereaza un raport nou
|
||||
|
||||
Private ptDataI, ptDataS, pnIdGrupaGest, pcGrupaGest, pnProcent, pnIdComRapVanz, llSucces
|
||||
Local loFrm, lcSql, lcCursor, lnSucces, lcCursor2, llGenereaza
|
||||
lcCursor = [crsraport]
|
||||
lcCursor2 = [crscantitati]
|
||||
ptDataS = IIF(!EMPTY(m.ttDataI), m.ttDataI, get_Ora())
|
||||
ptDataI = IIF(!EMPTY(m.ttDataS), m.ttDataS, m.ptDataS - 60 * 60 * 24)
|
||||
pnIdGrupaGest = Null
|
||||
pcGrupaGest = []
|
||||
|
||||
pnIdComRapVanz = tnIdComRapVanz
|
||||
llGenereaza = !EMPTY(m.pnIdComRapVanz)
|
||||
|
||||
If Empty(m.tnIdComRapVanz)
|
||||
pnProcent = citeste_optiune_firma('PROCVANZPER')
|
||||
loFrm = Createobject("frm_rap_vanz")
|
||||
loFrm.Show(1)
|
||||
If gnButon <> 1
|
||||
Return
|
||||
Endif
|
||||
|
||||
lcSql = [{call pack_comenzi.raport_proc_vanzari(?ptDataI,?ptDataS,?pnIdGrupaGest,?pnProcent,?gnId_sectie,?gnIdUtil,?gnIdSucursala)}]
|
||||
Else
|
||||
lcSql = [{call pack_comenzi.raport_proc_vanzari_viz(?pnIdComRapVanz)}]
|
||||
Endif
|
||||
|
||||
llSucces = goExecutor.oExecuta(lcSql, lcCursor)
|
||||
|
||||
If m.llSucces
|
||||
If Reccount(lcCursor) > 0
|
||||
* Select *, IIF(cantitate <> 0, 1, 0) as validat From (lcCursor) Into CURSOR (lcCursor2) Order By nume_gestiune, subgrupa, denumire READWRITE
|
||||
*!* IF TYPE(lcCursor + '.validat') = 'U'
|
||||
*!* Select *, IIF(cantitate <> 0, 1, 0) as validat From (lcCursor) Into CURSOR (lcCursor2) Order By nume_gestiune, subgrupa, denumire READWRITE
|
||||
*!* ELSE
|
||||
Select * From (lcCursor) Into CURSOR (lcCursor2) Order By nume_gestiune, subgrupa, denumire READWRITE
|
||||
SELECT (lcCursor2)
|
||||
INDEX on id_comrapvanzelem TAG id
|
||||
SET ORDER TO
|
||||
|
||||
Use In (Select(lcCursor))
|
||||
*!* ENDIF
|
||||
*!* copiaza_structura_cursor(lcCursor, lcCursor2)
|
||||
*!* lnSucces = -1
|
||||
*!* Insert Into (lcCursor2) Select * From (lcCursor) Order By nume_gestiune, subgrupa, denumire
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If Used(m.lcCursor2)
|
||||
Select (m.lcCursor2)
|
||||
Go Top
|
||||
pnIdComRapVanz = id_comrapvanz
|
||||
*!* Do While !llSucces
|
||||
loFrm = Createobject("frm_rap_vanz_cant", ptDataI, ptDataS, pnIdComRapVanz)
|
||||
loFrm.Show(1)
|
||||
If gnButon = 1
|
||||
llSucces = .T.
|
||||
IF m.llGenereaza
|
||||
listeaza_rap_vanz_per(m.pnIdComRapVanz)
|
||||
ENDIF
|
||||
*!* Else
|
||||
*!* llSucces = .F.
|
||||
*!* Endif
|
||||
ENDIF
|
||||
*!* Enddo
|
||||
Release pnIdComRapVanz
|
||||
Else
|
||||
amessagebox("Nu exista articole in perioada care sa aiba procentul de vanzari specificat!", 48, "Atentie")
|
||||
Endif
|
||||
|
||||
|
||||
|
||||
Use In (Select(lcCursor2))
|
||||
|
||||
Release loFrm, lcSql, lcCursor, lnSucces, ptDataI, ptDataS, pnIdGrupaGest, pcGrupaGest
|
||||
Endproc
|
||||
***************************************************************************************************************
|
||||
Function completeaza_rap_vanz_per
|
||||
Lparameters tnIdComRapVanz, tcCursorArt, tcCursorGest, tcCursor
|
||||
Local lcCursorTemp, lcCursorTemp2, lcIdArticole, lcIdGestiuni, llReturn, lnId, lcFiltru
|
||||
llReturn = .F.
|
||||
lcCursorTemp = Sys(2015)
|
||||
lcCursorTemp2 = Sys(2015)
|
||||
lcIdArticole = cursor2lista(tcCursorArt, "id_articol", ",")
|
||||
lcIdGestiuni = cursor2lista(tcCursorGest, "id_gestiune", ",")
|
||||
lcSql = [{call pack_comenzi.completeaza_raport(] + Alltrim(Str(tnIdComRapVanz)) + [,] + ;
|
||||
['] + Alltrim(lcIdArticole) + [','] + Alltrim(lcIdGestiuni) + [')}]
|
||||
lnSucces = goExecutor.oExecute(lcSql, lcCursorTemp)
|
||||
If lnSucces < 0
|
||||
amessagebox(goExecutor.cEroare, 0 + 48, "Eroare")
|
||||
Else
|
||||
Select (tcCursor)
|
||||
lcFiltru = Set('Filter')
|
||||
lnId = id_comrapvanzelem
|
||||
copiaza_structura_cursor(tcCursor, lcCursorTemp2)
|
||||
Insert Into (lcCursorTemp2) ;
|
||||
Select * From (lcCursorTemp) ;
|
||||
Union All ;
|
||||
Select * From (tcCursor)
|
||||
Use In (Select(tcCursor))
|
||||
copiaza_structura_cursor(lcCursorTemp2, tcCursor)
|
||||
Insert Into (tcCursor) Select * From (lcCursorTemp2) Order By nume_gestiune, subgrupa, denumire
|
||||
Use In (Select(lcCursorTemp))
|
||||
Use In (Select(lcCursorTemp2))
|
||||
Select (tcCursor)
|
||||
Set Filter To &lcFiltru
|
||||
Locate For id_comrapvanzelem = lnId
|
||||
llReturn = .T.
|
||||
Endif
|
||||
Release lcCursorTemp, lcCursorTemp2, lcIdArticole, lcIdGestiuni, lnId, lcFiltru
|
||||
Return llReturn
|
||||
Endfunc
|
||||
***************************************************************************************************************
|
||||
|
||||
|
||||
|
||||
***************************************************************************************************************
|
||||
* raport comenzi pe gestiuni bazat pe vanzarile dintr-o perioda
|
||||
***************************************************************************************************************
|
||||
Procedure listeaza_rap_vanz_per
|
||||
Lparameters tnIdComRapVanz, tnExportExcel
|
||||
Private ptDataRaport, pnIdComRapVanz
|
||||
Local lcSql, lcCursor, lnSucces, lnExportExcel
|
||||
If Type('tnExportExcel') = 'L'
|
||||
lnExportExcel = tnExportExcel
|
||||
Else
|
||||
lnExportExcel = .F.
|
||||
Endif
|
||||
ptDataRaport = Datetime()
|
||||
pnIdComRapVanz = tnIdComRapVanz
|
||||
lcSql = [{call pack_comenzi.listeaza_raport(?pnIdComRapVanz,?@ptDataRaport)}]
|
||||
lcCursor = [crslistare]
|
||||
lnSucces = goExecutor.oExecute(lcSql, lcCursor)
|
||||
If lnSucces < 0
|
||||
amessagebox(goExecutor.cEroare, 0 + 48, "Eroare")
|
||||
Else
|
||||
If lnExportExcel
|
||||
goExport.export2xls(lcCursor, [rap_comanda_vanz])
|
||||
Else
|
||||
goExport.export2frx(lcCursor, [rap_comanda_vanz])
|
||||
Endif
|
||||
Endif
|
||||
If Used(lcCursor)
|
||||
Use In (lcCursor)
|
||||
Endif
|
||||
Release ptDataRaport, pnIdComRapVanz, lcSql, lcCursor, lnSucces
|
||||
Endproc
|
||||
|
||||
***************************************************************************************************************
|
||||
* raport comenzi pe furnizori bazat pe vanzarile dintr-o perioda
|
||||
***************************************************************************************************************
|
||||
Procedure listeaza_rap_vanz_fz_per
|
||||
Lparameters tnIdComRapVanz, tlCantitate, tlExportExcel
|
||||
Private ptDataRaport, ptDataI, ptDataS, pnIdComRapVanz, pnCantitate
|
||||
Local lcSql, lcCursor, lnSucces, llExportExcel
|
||||
pnCantitate = IIF(Type('tlCantitate') = 'L', IIF(m.tlCantitate, 1, 0), 0) && daca se foloseste coloana "cantitate" sau "vanzari" pentru cantitate
|
||||
llExportExcel = IIF(Type('tlExportExcel') = 'L', m.tlExportExcel, .F.)
|
||||
|
||||
ptDataRaport = Datetime()
|
||||
ptDataI = Datetime()
|
||||
ptDataS = Datetime()
|
||||
pnIdComRapVanz = tnIdComRapVanz
|
||||
lcSql = [{call pack_comenzi.listeaza_raport_vz_fz(?pnIdComRapVanz, ?pnCantitate, ?@ptDataRaport,?@ptDataI,?@ptDataS)}]
|
||||
lcCursor = [crslistare]
|
||||
llSucces = goExecutor.oExecuta(lcSql, lcCursor)
|
||||
If m.llSucces
|
||||
SET FILTER TO cantitate <> 0 OR stocdep <> 0 IN (m.lcCursor)
|
||||
LOCATE FOR cantitate <> 0 OR stocdep <> 0
|
||||
IF !FOUND()
|
||||
AMESSAGEBOX('Nu exista inregistrari pentru listare!', 0+64, _screen.Caption)
|
||||
ELSE
|
||||
If m.llExportExcel
|
||||
goExport.export2xls(lcCursor, [rap_comanda_vanz_fz])
|
||||
Else
|
||||
goExport.export2frx(lcCursor, [rap_comanda_vanz_fz])
|
||||
ENDIF
|
||||
ENDIF
|
||||
Endif
|
||||
|
||||
Use In (SELECT(lcCursor))
|
||||
|
||||
Release ptDataRaport, pnIdComRapVanz, lcSql, lcCursor, llSucces
|
||||
Endproc
|
||||
***************************************************************************************************************
|
||||
***************************************************************************************************************
|
||||
Procedure listeaza_rap_vanz_fz_val_per
|
||||
Lparameters tnIdComRapVanz, tlCantitate, tnExportExcel
|
||||
Private ptDataRaport, ptDataI, ptDataS, pnIdComRapVanz, pnCantitate
|
||||
Local lcSql, lcCursor, lnSucces, llExportExcel
|
||||
pnCantitate = IIF(Type('tlCantitate') = 'L', IIF(m.tlCantitate, 1, 0), 0) && daca se foloseste coloana "cantitate" sau "vanzari" pentru cantitate
|
||||
llExportExcel = IIF(Type('tlExportExcel') = 'L', m.tlExportExcel, .F.)
|
||||
|
||||
ptDataRaport = Datetime()
|
||||
ptDataI = Datetime()
|
||||
ptDataS = Datetime()
|
||||
pnIdComRapVanz = tnIdComRapVanz
|
||||
lcSql = [{call pack_comenzi.listeaza_raport_vz_fz(?pnIdComRapVanz, ?pnCantitate, ?@ptDataRaport,?@ptDataI,?@ptDataS)}]
|
||||
lcCursor = [crslistare]
|
||||
llSucces = goExecutor.oExecuta(lcSql, lcCursor)
|
||||
If m.llSucces
|
||||
SET FILTER TO stoci<>0 OR stocf <> 0 OR cantitate <> 0 OR stocdep <> 0 IN (m.lcCursor)
|
||||
LOCATE FOR stoci<>0 OR stocf <> 0 OR cantitate <> 0 OR stocdep <> 0
|
||||
IF !FOUND()
|
||||
AMESSAGEBOX('Nu exista inregistrari pentru listare!', 0+64, _screen.Caption)
|
||||
ELSE
|
||||
If m.llExportExcel
|
||||
goExport.export2xls(lcCursor, [rap_comanda_vanz_fz_val])
|
||||
Else
|
||||
goExport.export2frx(lcCursor, [rap_comanda_vanz_fz_val])
|
||||
ENDIF
|
||||
ENDIF
|
||||
Endif
|
||||
Use In (SELECT(lcCursor))
|
||||
Release ptDataRaport, pnIdComRapVanz, lcSql, lcCursor, llSucces
|
||||
Endproc
|
||||
***************************************************************************************************************
|
||||
|
||||
***************************************************************************************************************
|
||||
* Detaliu vanzari articol, gestiune pe o perioada
|
||||
* Dbl Click pe coloana vanzari
|
||||
***************************************************************************************************************
|
||||
Procedure rap_vanz_per_detaliu
|
||||
Parameters tnIdComrapvanzElem
|
||||
|
||||
lcCursor = [crsCantitatiDetaliu]
|
||||
lcSql = [{call pack_comenzi.rap_vanz_per_detaliu(?tnIdComrapvanzElem)}]
|
||||
llSucces = goExecutor.oExecuta(lcSql, lcCursor)
|
||||
If m.llSucces
|
||||
If Reccount(m.lcCursor) > 0
|
||||
loFrm = Createobject("frm_rap_vanz_cant_detaliu")
|
||||
loFrm.Show(1)
|
||||
Else
|
||||
amessagebox("Nu exista articole in perioada care sa aiba procentul de vanzari specificat!", 48, "Atentie")
|
||||
Endif
|
||||
Endif
|
||||
Endproc
|
||||
Reference in New Issue
Block a user