Escolar Documentos
Profissional Documentos
Cultura Documentos
+----------------------------------------------------------------------------+
!
FICHA TECNICA DO PROGRAMA
!
+----------------------------------------------------------------------------+
!
DADOS DO PROGRAMA
!
+------------------+---------------------------------------------------------+
!Tipo
! Relatrio
!
+------------------+---------------------------------------------------------+
!Modulo
! FAT - FATURAMENTO
!
+------------------+---------------------------------------------------------+
!Nome
! RFAT001
!
+------------------+---------------------------------------------------------+
!Descricao
! Impresso de Packing List
!
+------------------+---------------------------------------------------------+
!Autor
! RODRIGO LACERDA P ARAUJO
!
+------------------+---------------------------------------------------------+
!Data de Criacao
! 29/09/2011
!
+------------------+---------------------------------------------------------+
*/
#include "totvs.ch"
#include "protheus.ch"
#include "topconn.ch"
User Function RFAT001(nrPedido,cTexto)
Private cRotina
:= PADR("RFAT001",10)
Private oFonte08
:= TFont():New('Arial',08,08,,.F.,,,,.T.,.F.,.F.)
Private oFonte08N
:= TFont():New('Arial',08,08,,.T.,,,,.T.,.F.,.F.)
Private oFonte09
:= TFont():New('Arial',09,09,,.F.,,,,.T.,.F.,.F.)
Private oFonte10
:= TFont():New('Arial',10,10,,.F.,,,,.T.,.F.,.F.)
Private oFonte10N
:= TFont():New('Arial',10,10,,.T.,,,,.T.,.F.,.F.)
Private oFonte11N
:= TFont():New('Arial',11,11,,.T.,,,,.T.,.F.,.F.)
Private oFonte12N
:= TFont():New('Arial',12,12,,.T.,,,,.T.,.F.,.F.)
Private oFonte14N
:= TFont():New('Arial',14,14,,.T.,,,,.T.,.F.,.F.)
Private oFonte20N
:= TFont():New('Arial',20,20,,.T.,,,,.T.,.F.,.F.)
Private oFonte28
:= TFont():New('Arial',28,28,,.F.,,,,.T.,.F.,.F.)
Private lPrim
:= .T.
Private nLin
:= 5000
Private nLinAux
:= 0
Private nLinAux2
:= 0
Private nLinAux3
:= 0
Private nPag
:= 0
Private cEmpresa
Private cPedido
:= nrPedido
Private cOBS
:= cTexto
Private nTotItens
:= fGetNumIt(cPedido)
Private nTotPag
:= 0
Private nSubTot
:= 0
Private nTotBru
:= 0
Private nTotLiq
:= 0
Private nTotVol
:= 0
Private nLinAuxx
:= 0
//Posio
nBCol1 :=
nBCol2 :=
nBCol3 :=
nBCol4 :=
nBCol5 :=
nBCol6 :=
nBCol7 :=
nBCol8 :=
Colunas Barra
50 //inicio
930 //QTDE
1130 //LIQUIDO
1400 //BRUTO
1650 //LOTE
1930 //VOLUME
2130 //EMBALA
2320 //fim
nCCol4
nCCol5
nCCol6
nCCol7
nCCol8
:=
:=
:=
:=
:=
//Posio
nVCol1 :=
nVCol2 :=
nVCol3 :=
nVCol4 :=
nVCol5 :=
nVCol6 :=
nVCol7 :=
1460
1770
1960
2160
2320
//BRUTO
//LOTE
//VOLUME
//EMBALA
//fim
Colunas Valores
62 //PRODUTO
1100 //QTDE
1370 //LIQUIDO
1630 //BRUTO
1780 //LOTE
2020 //VOLUME
2230 //EMBALA
:=
:=
:=
:=
:=
+=
+=
+=
+=
0
0
0
0
"
"
"
"
"
If ( SELECT("QRY") ) > 0
dbSelectArea("QRY")
QRY->(dbCloseArea())
EndIf
TCQUERY cQuery NEW ALIAS "QRY"
dbSelectArea("QRY")
dbGoTop()
ProcRegua(QRY->(RecCount()))
if QRY->(!Eof())
nLinN := nLinAuxx //3040
While QRY->(!Eof())
oPrint:Line(nLinN,nBCol1,nLinAux,nBCol1)
oPrint:Line(nLinN,nBCol8,nLinAux,nBCol8)
//borda esquerda
//borda direita
oPrint:Line(nLinN,nBCol1,nLinN,nBCol8)
dbSelectArea("SC5")
SC5->(dbSetOrder(1))
SC5->(dbGoTop())
SC5->(dbSeek(xFilial("SC5")+SZ1->Z1_PEDIDO))
cCodCli := SC5->C5_CLIENTE
cLojCli := SC5->C5_LOJACLI
_cProduto := QRY->Z1_PRODUTO
if _cProdAux != _cProduto
_cProdAux:=""
.and. !empty(_cProdAux)
oPrint:Line(nLin,nBCol2,nLin,nBCol3)
nLin+=20
oPrint:Say(nLin,nBCol2-50, "Subtotal: ", oFonte10,,,,1)
oPrint:Say(nLin,nVCol2, TRANSFORM(nSubTot,"@E
999,999.99"), oFonte10,,,,1)
nSubTot:= 0
nSubTot += QRY->Z1_QUANT
nLin+=50
oPrint:Line(nLin,nBCol1,nLin,nBCol8)
nLin+=20
oPrint:Say(nLin,nVCol1, fProduto(cCodCli,cLojCli,QRY>Z1_PRODUTO), oFonte09)
oPrint:Say(nLin,nVCol2, TRANSFORM(QRY->Z1_QUANT
, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol3, TRANSFORM(QRY->Z1_PESOLIQ, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol4, TRANSFORM(QRY->Z1_PESOBRU, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol5, QRY->Z1_OP
, oFonte09,,,,2)
oPrint:Say(nLin,nVCol6, QRY->Z1_VOLUME , oFonte09,,,,2)
oPrint:Say(nLin,nVCol7, QRY->Z1_EMBA
, oFonte09,,,,2)
nLin+=50
else
oPrint:Say(nLin,nVCol1, fProduto(cCodCli,cLojCli,QRY>Z1_PRODUTO), oFonte09)
oPrint:Say(nLin,nVCol2, TRANSFORM(QRY->Z1_QUANT
, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol3, TRANSFORM(QRY->Z1_PESOLIQ, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol4, TRANSFORM(QRY->Z1_PESOBRU, "@E
999,999.99"), oFonte09,,,,1)
oPrint:Say(nLin,nVCol5, QRY->Z1_OP
, oFonte09,,,,2)
oPrint:Say(nLin,nVCol6, QRY->Z1_VOLUME , oFonte09,,,,2)
oPrint:Say(nLin,nVCol7, QRY->Z1_EMBA
, oFonte09,,,,2)
nLin+=50
nSubTot += QRY->Z1_QUANT
_cProdAux := QRY->Z1_PRODUTO
endif
nTotalQ += QRY->Z1_QUANT
If nLin >= 2950
nLinAuxx := 3240
fQuebra()
else
nLinAuxx := 2950
endif
dbSelectArea("QRY")
QRY->(dbSkip())
EndDo
oPrint:Line(nLin,nBCol2,nLin,nBCol3)
nLin+=20
oPrint:Say(nLin,nBCol2-50, "Subtotal: ", oFonte10,,,,1)
oPrint:Say(nLin,nVCol2, TRANSFORM(nSubTot,"@E 999,999.99"),
oFonte10,,,,1)
nSubTot:= 0
EndIf
nLin := nLinAuxx
oPrint:Line(nLin,nBCol1,nLin,nBCol8)
nLin+=20
oPrint:Say(nLin,nBCol2-50, "Total: ", oFonte10,,,,1)
oPrint:Say(nLin,nVCol2, TRANSFORM(nTotalQ,"@E 999,999.99"), oFonte10,,,,1)
nLinAux := nLinAuxx
nLin+=100
oPrint:Line(nLin-20,nBCol1,nLin-20,nBCol8)
oPrint:Line(nLin-20,nBCol3,nLin+100,nBCol3)
oPrint:Say(nLin+10,0080, "Conferido por: " + __cUserID+"-"+cUserName, oFonte10)
oPrint:Say(nLin+10,1242, "Visto: ", oFonte10)
nLin+=100
oPrint:Line(nLin,nBCol1,nLin,nBCol8)
oPrint:Say(nLin+20,0080, "Obs: "+upper(cOBS), oFonte10)
nLin+=90
oPrint:EndPage(.T.)
Return
cTitulo
cPagina
:= "PACKING LIST"
:= "FOLHA "+ STRZERO(nPag,2) + " / " + STRZERO(nTotPag,2)
oPrint:Box(100,nBCol1,250,nBCol8)
oPrint:Line(100,500,250,500)
oPrint:Line(100,2000,250,2000)
oPrint:Say(150,100, cEmpresa , oFonte12N)
oPrint:Say(150,1100, cTitulo , oFonte14N,,,,2)
oPrint:Say(170,2280, cPagina , oFonte08,,,,1)
oPrint:Box(250,nBCol1,320,nBCol8)
oPrint:Line(250,1140,320,1140)
oPrint:Line(250,1500,320,1500)
oPrint:Line(250,1800,320,1800)
dbSelectArea("SC5")
SC5->(dbSetOrder(1))
SC5->(dbGoTop())
SC5->(dbSeek(xFilial("SC5")+SZ1->Z1_PEDIDO))
cCodCli := SC5->C5_CLIENTE
cLojCli := SC5->C5_LOJACLI
cCliente:= Posicione("SA1",1,xFilial("SA1")+cCodCli+cLojCli,"A1_NOME")
cNF
:= SC5->C5_NOTA
oPrint:Say(270,0070,
oFonte10)
oPrint:Say(270,1360,
oPrint:Say(270,1520,
oPrint:Say(270,2180,
oPrint:Box(320,nBCol1,390,nBCol8)
oPrint:Line(320,823,390,823)
oPrint:Line(320,1596,390,1596)
cQuery := " SELECT TOTALBRUTO,TOTALLIQ,TOTALVOL FROM ( "
cQuery += " SELECT "
cQuery += " (SELECT SUM(Z1_PESOBRU) FROM " + RetSqlName("SZ1") + " WHERE
Z1_FILIAL='" + xFilial("SZ1") + "' AND D_E_L_E_T_<>'*' AND Z1_PEDIDO='" + cPedido + "')
AS 'TOTALBRUTO' , "
cQuery += " (SELECT SUM(Z1_PESOLIQ) FROM " + RetSqlName("SZ1") + " WHERE
Z1_FILIAL='" + xFilial("SZ1") + "' AND D_E_L_E_T_<>'*' AND Z1_PEDIDO='" + cPedido + "'
) AS 'TOTALLIQ', "
cQuery += " ( "
cQuery += " SELECT COUNT(VOLUME) AS 'TOTALVOL' FROM ( "
cQuery += " SELECT Z1_VOLUME,COUNT(Z1_VOLUME) AS 'VOLUME' FROM " +
RetSqlName("SZ1") + " "
cQuery += " WHERE Z1_FILIAL='" + xFilial("SZ1") + "' AND D_E_L_E_T_<>'*' AND
Z1_PEDIDO='" + cPedido + "' "
cQuery += " GROUP BY Z1_VOLUME "
cQuery += " ) T2 "
cQuery += " ) AS 'TOTALVOL' "
cQuery += " )T1 "
If ( SELECT("TRB") ) > 0
dbSelectArea("TRB")
TRB->(dbCloseArea())
EndIf
TCQUERY cQuery NEW ALIAS "TRB"
dbSelectArea("TRB")
dbGoTop()
if TRB->(!Eof())
nTotBru := TRB->TOTALBRUTO
nTotLiq := TRB->TOTALLIQ
nTotVol := TRB->TOTALVOL
Endif
oPrint:Say(340,0220, "PESO BRUTO: "
+ TRANSFORM(nTotBru,"@E 999,999.99") ,
oFonte10)
oPrint:Say(340,1100, "PESO LIQUIDO: " + TRANSFORM(nTotLiq,"@E 999,999.99") ,
oFonte10)
oPrint:Say(340,1760, "QTDE VOLUME: " + TRANSFORM(nTotVol,"@E 99,999") ,
oFonte10)
nLin := 390
nLinAux := nLin
oPrint:Box(nLin,nBCol1,nLin+70,nBCol8)
nLin+=20
oPrint:Say(nLin,nCCol1,
oPrint:Say(nLin,nCCol2,
oPrint:Say(nLin,nCCol3,
oPrint:Say(nLin,nCCol4,
oPrint:Say(nLin,nCCol5,
oPrint:Say(nLin,nCCol6,
oPrint:Say(nLin,nCCol7,
nLin+=65
"Produto"
"QTDE"
,
"Peso Liquido" ,
"Peso Bruto" ,
"Lote"
"Nr.Volume"
,
"Nr.Embala"
,
, oFonte10)
oFonte10)
oFonte10)
oFonte10)
, oFonte10)
oFonte10)
oFonte10)
Return
EndIf
Else
dbSelectArea("SB1")
dbSetOrder(1)
dbGoTop()
dbSeek(xFilial("SB1")+cProduto)
cDescri := ALLTRIM(SB1->B1_COD) + " - " + ALLTRIM(SB1->B1_DESC)
EndIf
Return(cDescri)
Z0_OP
dbSelectArea("TRB")
If TRB->(!EOF())
if TRB->SEQ == 0
nUltSeq := 1
else
nUltSeq := TRB->SEQ
endif
endif
Return(nUltSeq)