#include 'protheus.ch' #include 'parmtype.ch' #INCLUDE "TOPCONN.CH" #INCLUDE "FWPrintSetup.ch" #INCLUDE "TBICONN.CH" #INCLUDE "COLORS.CH" #INCLUDE "RPTDEF.CH" #DEFINE IMP_SPOOL 2 #IFNDEF CRLF #DEFINE CRLF Chr(13)+Chr(10) #EndIF /* ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³ PESQNFE º Autor ³ TOTVS RP º Data ³ 31/12/19 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Histórico nota fiscal de Entrada º±± ±±º ³ º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºUso ³ Doma - Genéricos º±± ±±ÈÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß */ User Function PESQNFE(cCodigo) Local aArea := GetArea() Local nOpcGet := GD_INSERT+GD_UPDATE+GD_DELETE Local oDlg Local aSize := {}, aObjects := {}, aInfo := {}, aPObjs := {} Private oGetDad, oPanel, oTotQtd, oTotVal Private nPosPrd := 0 Private aHeader := {}, aCols := {} Private cFieldOk :="" // funcao para validacao apos confirmar digitacao de um campo da getdados Private cLinOk :="allwaystrue()" // funcao para validar mudanca de linha na getdados Private cTudOk :="allwaystrue()" // validacao para botao de confimacao (OK) do modelo 3 Private oFont:= TFont():New("Courier New",,45,,.T.) Private oFont1:= TFont():New("Courier New",,38,,.T.) Private oFont2:= TFont():New("Courier New",,14,,.T.) Private oFont3:= TFont():New("Courier New",,13,,.T.) Private nTotQtd := 0 Private nTotVal := 0 cPerg := "PESQNFE" // padr("PESQNFE",Len(SX1->X1_GRUPO)) // GeraX1(cPerg) AjustaSX1(cPerg) IF !Pergunte(cPerg,.T.) return() ENDIF dDATADE := MV_PAR01 dDATAAT := MV_PAR02 cSERDE := MV_PAR03 cSERAT := MV_PAR04 cTIPDE := MV_PAR05 cTIPAT := MV_PAR06 cESTDE := MV_PAR07 cESTAT := MV_PAR08 cNOME := MV_PAR09 aSize := MsAdvSize(.T.) aObjects := {} aAdd( aObjects, { 100, 010, .T.,.T., .T.} ) aAdd( aObjects, { 100, 080, .T.,.T., .T.} ) aAdd( aObjects, { 100, 010, .T.,.T., .T.} ) aInfo := { aSize[ 1 ], aSize[ 2 ], aSize[ 3 ], aSize[ 4 ], 0, 0 } aPObjs := MsObjSize( aInfo, aObjects, .T. ) GerHead() Processa({|| AtuMntCol(.T.,cCodigo) },"Processando...") DEFINE MSDIALOG oDlg TITLE OemToAnsi("Nota de Entrada") From aSize[7], 000 To aSize[6], aSize[5] Of oMainWnd Pixel oPanel := TPanel():New(aPObjs[1, 2], aPObjs[1, 2],, oDlg,,,,,, aPObjs[1, 3], aPObjs[1, 4]) oPanel:Align := CONTROL_ALIGN_TOP @005, 005 Say OemToAnsi("Quantidade.:") OF oPanel PIXEL COLOR CLR_BLUE @005, 045 MSGet oTotQtd var nTotQtd PICTURE "@E 999,999.99" Size 060, 004 WHEN .F. OF oPanel PIXEL COLOR CLR_BLACK @005, 130 Say OemToAnsi("Total.:") OF oPanel PIXEL COLOR CLR_BLUE @005, 160 MSGet oTotVal var nTotVal PICTURE "@E 999,999.99" Size 060, 004 WHEN .F. OF oPanel PIXEL COLOR CLR_BLACK oGetDad:= MsNewGetDados():New(aPObjs[2, 1], aPObjs[2, 2], aPObjs[2, 3], aPObjs[2, 4], nOpcGet, cLinOk, cTudOk,,,, 99999, cFieldOk,,,, aHeader, aCols) oGetDad:oBrowse:Align := CONTROL_ALIGN_ALLCLIENT oPPesq := tPanel():New(aPObjs[3,1], aPObjs[3,2],, oDlg,,,,,, aPObjs[3,3], aPObjs[3,4]) oPPesq:Align := CONTROL_ALIGN_BOTTOM HS_GDPesqu( , , oGetDad, oPPesq, 01) oBtnTransf := tButton():New(002, aPObjs[1, 3] - 250, "Exportar",oPPesq, {|| GDToExcel(aHeader,aCols)}, 070, 015,,oFont2,, .T.) oBtnTransf := tButton():New(002, aPObjs[1, 3] - 160, "Nova Pesquisa",oPPesq, {|| Pergunta(cCodigo)}, 070, 015,,oFont2,, .T.) oBtnFecha := tButton():New(002, aPObjs[1, 3] - 80, "Fechar",oPPesq, {|| oDlg:End()}, 055, 015,,oFont2,, .T.) @ 005, aSize[3]-100 Button oBtn PROMPT "Exp. Grafico" Size 040, 15 Action (U_grafico_teste(aCols)) OF oPanel Pixel ACTIVATE MSDIALOG oDlg CENTERED RestArea(aArea) Return(Nil) /* ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³ GerHead º Autor ³ TOTVS RP º Data ³ 31/12/19 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Monta o aHeader º±± ±±º ³ º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºUso ³ PESQNFE º±± ±±ÈÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß */ Static Function GerHead() aAdd(aHeader, {"Filial" , "cZ8FILIAL", "@!" , TamSX3("Z8_FILIAL")[1] , TamSX3("Z8_FILIAL")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Serie" , "cZ8SER" , "@!" , TamSX3("Z8_SERIE")[1] , TamSX3("Z8_SERIE")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Tipo" , "cZ8TIPO" , "@!" , TamSX3("Z8_TIPO")[1] , TamSX3("Z8_TIPO")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"CFOP" , "cZ8CFOP" , "@!" , TamSX3("Z8_CFOP")[1] , TamSX3("Z8_CFOP")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Estoque" , "cZ8ESTQ" , "@!" , TamSX3("Z8_ESTOQUE")[1] , TamSX3("Z8_ESTOQUE")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Emissão" , "dDATAEM" , " " , TamSX3("Z8_EMISSAO")[1] , TamSX3("Z8_EMISSAO")[2] ,,, "D", , "R",,,, "V"}) aAdd(aHeader, {"Dt.Entrada" , "dDATAET" , " " , TamSX3("Z8_DTENTRA")[1] , TamSX3("Z8_DTENTRA")[2] ,,, "D", , "R",,,, "V"}) aAdd(aHeader, {"Dt.Cancela" , "dDATACA" , " " , TamSX3("Z8_DTCANCE")[1] , TamSX3("Z8_DTCANCE")[2] ,,, "D", , "R",,,, "V"}) aAdd(aHeader, {"Documento" , "cZ8DOC" , "@!" , TamSX3("Z8_DOC")[1] , TamSX3("Z8_DOC")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Fornecedor" , "cZ8FOR" , "@!" , TamSX3("Z8_FORNECE")[1] , TamSX3("Z8_FORNECE")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Loja" , "cZ6FORL" , "@!" , TamSX3("Z8_LOJA")[1] , TamSX3("Z8_LOJA")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Nome" , "cZ6FORN" , "@S40" , TamSX3("Z8_NOME")[1] , TamSX3("Z8_NOME")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Produto" , "cZ9CODBAR", "@!" , TamSX3("Z9_CODBARR")[1] , TamSX3("Z9_CODBARR")[2] ,,, "C", ,"R",,,, "V"}) aAdd(aHeader, {"Descrição" , "cZ9DESC" , "@S40" , TamSX3("Z9_DESCRIC")[1] , TamSX3("Z9_DESCRIC")[2] ,,, "C", ,"R",,,, "V"}) aAdd(aHeader, {"Marca" , "cZ9MARCA" , "@S30" , TamSX3("Z9_MARCA")[1] , TamSX3("Z9_MARCA")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Qtdade" , "nZ9QUANT" , "@E 99999999999.99" , TamSX3("Z9_QUANT")[1] , TamSX3("Z9_QUANT")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.Prod." , "nZ9VLUNI" , "@E 99,999,999,999.9999", TamSX3("Z9_VLUNIT")[1] , TamSX3("Z9_VLUNIT")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.ICMS" , "nZ9ICMS" , "@E 99,999,999,999.9999", TamSX3("Z9_VALICM")[1] , TamSX3("Z9_VALICM")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Sub.Total." , "nZ9SUBTO" , "@E 99,999,999,999.9999", TamSX3("Z9_SUBTOT")[1] , TamSX3("Z9_SUBTOT")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.IPI" , "nZ9IPI" , "@E 99,999,999,999.9999", TamSX3("Z9_VALIPI")[1] , TamSX3("Z9_VALIPI")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.Frete" , "nZ9FRETE" , "@E 99,999,999,999.9999", TamSX3("Z9_VALFRE")[1] , TamSX3("Z9_VALFRE")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.ST" , "nZ9VLST" , "@E 99,999,999,999.9999", TamSX3("Z9_STICMS")[1] , TamSX3("Z9_STICMS")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.DESP" , "nZ9QTDES" , "@E 99999999999.99" , TamSX3("Z9_QTDESP")[1] , TamSX3("Z9_QTDESP")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Vlr.Unit.Total", "nZ9PRECO" , "@E 99,999,999,999.9999", TamSX3("Z9_PRCVEN")[1] , TamSX3("Z9_PRCVEN")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Total" , "nZ9TOTAL" , "@E 999,999,999.99", TamSX3("D1_TOTAL")[1] , TamSX3("D1_TOTAL")[2] ,,, "N", , "R",,,, "V"}) aAdd(aHeader, {"Lote" , "nZ9LOTE" , "", TamSX3("D1_LOTECTL")[1] , TamSX3("D1_LOTECTL")[2] ,,, "C", , "R",,,, "V"}) aAdd(aHeader, {"Validade" , "nZ9VAL" , "", TamSX3("D1_DTVALID")[1] , TamSX3("D1_DTVALID")[2] ,,, "D", , "R",,,, "V"}) aAdd(aHeader, {"Denegada" , "cZ8DENEG" , "@!" , TamSX3("Z8_DENAGAD")[1] , TamSX3("Z8_DENAGAD")[2] ,,, "C", , "R",,,, "V"}) nPosPrd := aScan(aHeader, {|aVet| AllTrim(aVet[2]) == "cZ9CODBAR" }) Return() /* ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³ AtuMntCol º Autor ³ TOTVS RP º Data ³ 31/12/19 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Monta o aCols º±± ±±º ³ º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºUso ³ PESQNFE º±± ±±ÈÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß */ Static Function AtuMntCol(lInicio,cCodigo) Local aArea := GetArea() Local cSql := "" Local cSql2 := "" nTotQtd := 0 nTotVal := 0 aCols := {} cSql := " SELECT SZ8.Z8_FILIAL, SZ8.Z8_DOC, SZ8.Z8_SERIE, SZ8.Z8_TIPO, SZ8.Z8_FORNECE, SZ8.Z8_LOJA, SZ8.Z8_NOME, SZ9.Z9_CODBARR, SZ9.Z9_DESCRIC " cSql += " ,(SELECT B1_XDESCM FROM SB1010 WHERE B1_COD = SZ9.Z9_CODBARR AND D_E_L_E_T_ = '') AS 'Z9_MARCA', SZ9.Z9_QUANT AS QUANT, //cSql += " SUM(SZ9.Z9_PRCVEN) AS PRCVEN, SUM(SZ9.Z9_VLUNIT) AS VLUNIT, SUM(SZ9.Z9_TOTAL) AS TOTAL," cSql += " SZ9.Z9_QUANT AS QUANT," cSql += " Z9_PRCVEN AS PRCVEN," cSql += " Z9_VLUNIT AS VLUNIT," cSql += " Z9_PRCVEN * SZ9.Z9_QUANT AS TOTAL," /*cSql += " (SELECT " cSql += " TOP 1" cSql += " Z9_PRCVEN" cSql += " FROM SZ9010" cSql += " WHERE Z9_CODBARR = SZ9.Z9_CODBARR" cSql += " AND Z9_DOC = SZ8.Z8_DOC AND Z9_ESTOQUE = SZ8.Z8_ESTOQUE " cSql += " AND Z9_SERIE = SZ9.Z9_SERIE ) AS PRCVEN," cSql += " (SELECT " cSql += " TOP 1" cSql += " Z9_VLUNIT" cSql += " FROM SZ9010" cSql += " WHERE Z9_CODBARR = SZ9.Z9_CODBARR" cSql += " AND Z9_DOC = SZ8.Z8_DOC AND Z9_ESTOQUE = SZ8.Z8_ESTOQUE " cSql += " AND Z9_SERIE = SZ9.Z9_SERIE ) AS VLUNIT," cSql += " (SELECT " cSql += " TOP 1" cSql += " Z9_PRCVEN * SZ9.Z9_QUANT" cSql += " FROM SZ9010" cSql += " WHERE Z9_CODBARR = SZ9.Z9_CODBARR" cSql += " AND Z9_DOC = SZ8.Z8_DOC AND Z9_ESTOQUE = SZ8.Z8_ESTOQUE " cSql += " AND Z9_SERIE = SZ9.Z9_SERIE ) AS TOTAL"*/ cSql += " SZ9.Z9_VALICM AS VALICM " /*cSql += " (SELECT " cSql += " TOP 1" cSql += " Z9_SUBTOT" cSql += " FROM SZ9010" cSql += " WHERE Z9_CODBARR = SZ9.Z9_CODBARR" cSql += " AND Z9_DOC = SZ8.Z8_DOC AND Z9_ESTOQUE = SZ8.Z8_ESTOQUE " cSql += " AND Z9_SERIE = SZ9.Z9_SERIE ) AS SUBTOT" */ cSql += " ,SZ9.Z9_SUBTOT AS SUBTOT, cSql += " SZ9.Z9_VALIPI AS VALIPI, SZ9.Z9_VALFRE AS VALFRE, SZ9.Z9_STICMS AS STICMS " cSql += " ,SZ9.Z9_QTDESP AS QTDESP, SZ9.Z9_ESTOQUE, SZ8.Z8_DENAGAD, SZ8.Z8_CFOP, SZ8.Z8_EMISSAO, SZ8.Z8_DTENTRA, SZ8.Z8_DTCANCE " cSql += " FROM " + RetSQLName("SZ9") + " SZ9 " cSql += " INNER JOIN " + RetSqlName("SZ8") + " SZ8 ON SZ8.D_E_L_E_T_ = '' AND SZ8.Z8_FILIAL = '" + xFilial("SZ8") + "' " cSql += " AND SZ8.Z8_DOC = SZ9.Z9_DOC AND SZ8.Z8_SERIE = SZ9.Z9_SERIE AND SZ8.Z8_FORNECE = SZ9.Z9_FORNECE AND SZ8.Z8_LOJA = SZ9.Z9_LOJA " If ! Empty(dDATADE) .And. ! Empty(dDATAAT) cSql += " AND SZ8.Z8_DTENTRA BETWEEN '" + DTOS(dDATADE) + "' AND '" + DTOS(dDATAAT) + "' " EndIf If ! Empty(cSERDE) .AND. ! Empty(cSERAT) cSql += " AND SZ8.Z8_SERIE BETWEEN '" + cSERDE + "' AND '" + cSERAT + "' " EndIf If ! Empty(cTIPDE) .And. ! Empty(cTIPAT) cSql += " AND SZ8.Z8_TIPO BETWEEN '" + cTIPDE + "' AND '" + cTIPAT + "' " EndIf If ! Empty(cESTDE) .AND. ! Empty(cESTAT) cSql += " AND SZ9.Z9_ESTOQUE BETWEEN '" + cESTDE + "' AND '" + cESTAT + "' " EndIf If ! Empty(cNOME) cSql += " AND SZ8.Z8_NOME LIKE '%"+ AllTrim(UPPER(cNOME)) + "%' " EndIf cSql += " WHERE SZ9.D_E_L_E_T_ = ' ' AND SZ9.Z9_FILIAL = '" + xFilial("SZ9") + "' AND SZ9.Z9_CODBARR = '" + cCodigo + "'"// AND SZ8.Z8_ESTOQUE = 'E' AND SZ9.Z9_ESTOQUE = 'E' " //cSql += " GROUP BY SZ8.Z8_FILIAL, SZ8.Z8_DOC, SZ8.Z8_SERIE, SZ8.Z8_TIPO, SZ8.Z8_FORNECE, SZ8.Z8_LOJA, SZ8.Z8_NOME, SZ9.Z9_CODBARR, SZ9.Z9_DESCRIC " //cSql += " ,SZ9.Z9_MARCA, SZ8.Z8_ESTOQUE, SZ8.Z8_DENAGAD, SZ8.Z8_CFOP, SZ8.Z8_EMISSAO, SZ8.Z8_DTENTRA, SZ8.Z8_DTCANCE, SZ9.Z9_SERIE " //cSql += " ,Z9_VALICM, Z9_SUBTOT,Z9_VALIPI,Z9_VALFRE,Z9_STICMS,Z9_QTDESP,Z8_ESTOQUE,Z8_CFOP,Z9_QUANT" cSql += " ORDER BY SZ8.Z8_DTENTRA, SZ8.Z8_DOC, SZ8.Z8_SERIE " cSql := ChangeQuery(cSql) //HS_MSGINF(cSQL,"","") TCQUERY cSql NEW ALIAS "QSZ9" DbSelectArea("QSZ9") While ! Eof() AADD(aCols,{AllTrim(QSZ9->Z8_FILIAL), AllTrim(QSZ9->Z8_SERIE), AllTrim(QSZ9->Z8_TIPO), AllTrim(QSZ9->Z8_CFOP), AllTrim(QSZ9->Z9_ESTOQUE),; STOD(QSZ9->Z8_EMISSAO), STOD(QSZ9->Z8_DTENTRA), STOD(QSZ9->Z8_DTCANCE), AllTrim(QSZ9->Z8_DOC), AllTrim(QSZ9->Z8_FORNECE), AllTrim(QSZ9->Z8_LOJA),; AllTrim(QSZ9->Z8_NOME), AllTrim(QSZ9->Z9_CODBARR), AllTrim(QSZ9->Z9_DESCRIC), AllTrim(QSZ9->Z9_MARCA), QSZ9->QUANT, QSZ9->PRCVEN, QSZ9->VALICM, QSZ9->SUBTOT,; QSZ9->VALIPI, QSZ9->VALFRE, QSZ9->STICMS, QSZ9->QTDESP, QSZ9->VLUNIT, QSZ9->TOTAL,"","",AllTrim(QSZ9->Z8_DENAGAD), .F.} ) nTotQtd += QSZ9->QUANT nTotVal += QSZ9->TOTAL QSZ9->(DbSkip()) EndDo QSZ9->(DbCloseArea()) cSql2 := "SELECT " cSql2 += "SF1.F1_FILIAL, " cSql2 += "SF1.F1_DOC, " cSql2 += "SF1.F1_SERIE, " cSql2 += "SF1.F1_TIPO, " cSql2 += "SF1.F1_FORNECE, " cSql2 += "SF1.F1_LOJA, " cSql2 += " (CASE WHEN (F1_TIPO = 'D')" cSql2 += " THEN ((SELECT A1_NOME FROM SA1010 WHERE A1_COD = SF1.F1_FORNECE AND A1_LOJA = SF1.F1_LOJA)) " cSql2 += " ELSE (SA2.A2_NOME) " cSql2 += " END) AS A2_NOME," cSql2 += "SD1.D1_COD, " cSql2 += "SB1.B1_DESC, " cSql2 += "SB1.B1_XDESCM, " cSql2 += "SD1.D1_QUANT AS QUANT, " cSql2 += "CASE WHEN D1_ICMSRET=0 THEN (round((D1_TOTAL-D1_VALDESC-D1_VALICM)/D1_QUANT,4)) ELSE (round((D1_TOTAL-D1_VALDESC)/D1_QUANT,4)) END AS PRCVEN, " cSql2 += "round((D1_TOTAL-D1_VALDESC+D1_VALIPI+D1_VALFRE+D1_ICMSRET+D1_X_OUTR)/D1_QUANT,4) AS VLUNIT, " cSql2 += "round(D1_TOTAL-D1_VALDESC+D1_VALIPI+D1_VALFRE+D1_ICMSRET+D1_X_OUTR,2) AS TOTAL, " cSql2 += "CASE WHEN D1_ICMSRET=0 THEN (round((D1_VALICM)/D1_QUANT,4)) ELSE (0) END AS VALICM, " cSql2 += "ROUND((D1_TOTAL-D1_VALDESC)/D1_QUANT,4) AS SUBTOT, " cSql2 += "ROUND(D1_VALIPI/D1_QUANT,4) AS VALIPI, " cSql2 += "ROUND(D1_VALFRE/D1_QUANT,4) AS VALFRE," cSql2 += "ROUND(D1_ICMSRET/D1_QUANT,4) AS STICMS, " cSql2 += "ROUND(D1_X_OUTR/D1_QUANT,4) AS QTDESP, " cSql2 += "SF1.F1_TIPO, " cSql2 += "'' AS F1_DENAGAD, " cSql2 += "SD1.D1_CF, " cSql2 += "SF1.F1_EMISSAO, " cSql2 += "SF1.F1_DTDIGIT, " cSql2 += "'' AS F1_DTCANCE " cSql2 += " ,D1_LOTECTL LOTE" cSql2 += " ,CASE WHEN D1_LOTECTL<>'' THEN (FORMAT(CONVERT(DATE,D1_DTVALID, 103), 'dd/MM/yy')) ELSE ('') END VALIDADE " cSql2 += "FROM SD1010 SD1 " cSql2 += "INNER JOIN SF1010 SF1 ON SF1.D_E_L_E_T_ = ' ' " cSql2 += "AND SF1.F1_DOC = SD1.D1_DOC AND SF1.F1_SERIE = SD1.D1_SERIE AND SF1.F1_FORNECE = SD1.D1_FORNECE AND SF1.F1_LOJA = SD1.D1_LOJA " If ! Empty(dDATADE) .And. ! Empty(dDATAAT) cSql2 += " AND SF1.F1_DTDIGIT BETWEEN '" + DTOS(dDATADE) + "' AND '" + DTOS(dDATAAT) + "' " EndIf If ! Empty(cSERDE) .AND. ! Empty(cSERAT) cSql2 += " AND SF1.F1_SERIE BETWEEN '" + cSERDE + "' AND '" + cSERAT + "' " EndIf If ! Empty(cTIPDE) .And. ! Empty(cTIPAT) cSql2 += " AND SF1.F1_TIPO BETWEEN '" + cTIPDE + "' AND '" + cTIPAT + "' " EndIf If ! Empty(cESTDE) .AND. ! Empty(cESTAT) cSql2 += " AND SF1.F1_TIPO BETWEEN '" + cESTDE + "' AND '" + cESTAT + "' " EndIf If ! Empty(cNOME) cSql2 += " AND SA2.A2_NOME LIKE '%"+ AllTrim(UPPER(cNOME)) + "%' " EndIf cSql2 += "INNER JOIN SB1010 SB1 ON SB1.B1_COD = SD1.D1_COD AND SB1.D_E_L_E_T_ = '' " cSql2 += "INNER JOIN SA2010 SA2 ON SA2.A2_COD = SF1.F1_FORNECE AND SF1.F1_LOJA = SA2.A2_LOJA AND SA2.D_E_L_E_T_ = '' " cSql2 += "WHERE SD1.D_E_L_E_T_ = ' ' AND SD1.D1_COD = '" + cCodigo + "' " //cSql2 += "GROUP BY SF1.F1_FILIAL, SF1.F1_DOC, SF1.F1_SERIE, SF1.F1_TIPO, SF1.F1_FORNECE, SF1.F1_LOJA, " //cSql2 += "SD1.D1_COD, SF1.F1_TIPO, SD1.D1_CF, SA2.A2_NOME, SB1.B1_DESC, SB1.B1_XDESCM, " //cSql2 += "SF1.F1_EMISSAO, SF1.F1_DTDIGIT " //cSql2 += "ORDER BY SF1.F1_DTDIGIT, SF1.F1_DOC, SF1.F1_SERIE " cSql2 += " UNION" cSql2 += " SELECT" cSql2 += " SD2.D2_FILIAL,SD2.D2_DOC,SD2.D2_SERIE," cSql2 += " 'D' AS D2_TIPO," cSql2 += " SD2.D2_CLIENTE,SF2.F2_LOJA," cSql2 += " SF2.F2_XNCLI,SD2.D2_COD," cSql2 += " SB1.B1_DESC,SB1.B1_XDESCM," cSql2 += " - SUM(SD2.D2_QUANT) AS QUANT," cSql2 += " - SUM(SD2.D2_PRCVEN + (D2_DESCON/D2_QUANT)) AS PRCVEN," cSql2 += " - SUM(D2_PRUNIT) PRCUNIT,- SUM(SD2.D2_TOTAL) AS TOTAL," cSql2 += " D2_VALICM VALICM," cSql2 += " 0 AS SUBTOT," cSql2 += " ROUND(D2_VALIPI/D2_QUANT,4) AS VALIPI," cSql2 += " ROUND(D2_VALFRE/D2_QUANT,4) AS VALFRE," cSql2 += " ROUND(D2_ICMSRET/D2_QUANT,4) AS STICMS," cSql2 += " 0 QTDESP," cSql2 += " SF2.F2_TIPO,' ' AS F2_DENEGAD,SD2.D2_CF,SF2.F2_EMISSAO,SF2.F2_EMISSAO," cSql2 += " '' DTCANCE,SD2.D2_LOTECTL," cSql2 += " CASE WHEN SD2.D2_LOTECTL<>' ' THEN (FORMAT(CONVERT(DATE,D2_DTVALID,103),'dd/MM/yy')) ELSE (' ') END VALIDADE" cSql2 += " FROM SD2010 SD2 " cSql2 += " JOIN SC5010 SC5 ON D2_PEDIDO = C5_NUM AND D2_FILIAL = C5_FILIAL " cSql2 += " AND SD2.D_E_L_E_T_=' ' AND SC5.D_E_L_E_T_ = ' ' JOIN SC6010 SC6 ON D2_PEDIDO = C6_NUM" cSql2 += " AND D2_FILIAL = C6_FILIAL AND SD2.D2_COD = C6_PRODUTO AND SC5.D_E_L_E_T_ = ' ' " cSql2 += " INNER JOIN SF2010 SF2 ON SF2.D_E_L_E_T_ = ' ' AND SF2.F2_DOC = SD2.D2_DOC AND SF2.F2_FILIAL = SD2.D2_FILIAL" cSql2 += " AND SF2.F2_EMISSAO BETWEEN '" + DTOS(dDATADE) + "' AND '" + DTOS(dDATAAT) + "' INNER JOIN SB1010 SB1 ON SB1.D_E_L_E_T_ = ' '" cSql2 += " AND SB1.B1_COD = SD2.D2_COD " cSql2 += " WHERE SD2.D_E_L_E_T_ = ' ' AND SD2.D2_COD = '" + cCodigo + "'" cSql2 += " AND C5_X_TPOPE NOT IN ('08','14','16') AND F2_TIPO = 'D'" cSql2 += " GROUP BY SF2.F2_FILIAL, SF2.F2_DOC, SF2.F2_SERIE, SF2.F2_TIPO, SF2.F2_CLIENTE," cSql2 += " SF2.F2_LOJA, SD2.D2_COD, SF2.F2_TIPO,SF2.F2_EMISSAO, D2_FILIAL, D2_DOC, D2_SERIE," cSql2 += " D2_TIPO, D2_CLIENTE, SB1.B1_DESC, SB1.B1_XDESCM, SD2.D2_CF ,SF2.F2_XNCLI, " cSql2 += " SF2.F2_XNVEND, SD2.D2_LOTECTL,D2_DTVALID,C5_X_TPOPE,C6_XTIPPRE, D2_VALICM ,D2_VALIPI,D2_VALIPI,D2_ICMSRET,D2_QUANT,D2_VALFRE" cSql2 += " ORDER BY SF1.F1_DTDIGIT, SF1.F1_DOC, SF1.F1_SERIE " cSql2 := ChangeQuery(cSql2) //HS_MSGINF(cSql2,"","") TCQUERY cSql2 NEW ALIAS "QSD1" DbSelectArea("QSD1") While ! Eof() AADD(aCols,{AllTrim(QSD1->F1_FILIAL ), AllTrim(QSD1->F1_SERIE), AllTrim(QSD1->F1_TIPO), AllTrim(QSD1->D1_CF), AllTrim(QSD1->F1_TIPO),; STOD(QSD1->F1_EMISSAO), STOD(QSD1->F1_DTDIGIT), STOD(QSD1->F1_DTCANCE), AllTrim(QSD1->F1_DOC), AllTrim(QSD1->F1_FORNECE), AllTrim(QSD1->F1_LOJA),; AllTrim(QSD1->A2_NOME), AllTrim(QSD1->D1_COD), AllTrim(QSD1->B1_DESC), AllTrim(QSD1->B1_XDESCM), QSD1->QUANT, QSD1->PRCVEN, QSD1->VALICM, QSD1->SUBTOT,; QSD1->VALIPI, QSD1->VALFRE, QSD1->STICMS, QSD1->QTDESP, QSD1->VLUNIT, QSD1->TOTAL, AllTrim(QSD1->LOTE), AllTrim(QSD1->VALIDADE), AllTrim(QSD1->F1_DENAGAD), .F.} ) nTotQtd += QSD1->QUANT nTotVal += QSD1->TOTAL QSD1->(DbSkip()) EndDo QSD1->(DbCloseArea()) If !lInicio oGetDad:SetArray(aCols) oGetDad:oBrowse:Refresh() oTotQtd:Refresh() oTotVal:Refresh() Endif RestArea(aArea) Return() /* ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³ Pergunta º Autor ³ TOTVS RP º Data ³ 31/12/19 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Processamento do aAcols º±± ±±º ³ º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºUso ³ PESQNFE º±± ±±ÈÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß */ Static function Pergunta(cCodigo) Local aArea := GetArea() cPerg := "PESQNFE" // padr("PESQNFE",Len(SX1->X1_GRUPO)) // GeraX1(cPerg) AjustaSX1(cPerg) IF !Pergunte(cPerg,.T.) return() ENDIF dDATADE := MV_PAR01 dDATAAT := MV_PAR02 cSERDE := MV_PAR03 cSERAT := MV_PAR04 cTIPDE := MV_PAR05 cTIPAT := MV_PAR06 cESTDE := MV_PAR07 cESTAT := MV_PAR08 cNOME := MV_PAR09 Processa({|| AtuMntCol(.F.,cCodigo) },"Processando...") RestArea(aArea) Return() /*/ ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³AjustaSX1 º Autor ³ Serpcom Tecnologia ºData ³ 03/03/2023 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Verifica se existe a pergunta, caso não exista será criado º±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß /*/ Static Function AjustaSX1(cPerg) ********************************************************************************************* * Ajusta o arquivo de Perguntas * *************** Local aHelp := {} Aadd(aHelp,{{""},{""},{""}}) u_PutSX1SN(cPerg, '01', 'Data Entrada de ? ', '', '', 'mv_ch1', 'D',08, 0, 0, 'G', '', '' , '', '', 'mv_par01','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '02', 'Data Entrada ate ? ', '', '', 'mv_ch2', 'D',08, 0, 0, 'G', '', '' , '', '', 'mv_par02','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '03', 'Serie de ? ', '', '', 'mv_ch3', 'C',03, 0, 0, 'G', '', '' , '', '', 'mv_par03','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '04', 'Serie ate ? ', '', '', 'mv_ch4', 'C',03, 0, 0, 'G', '', '' , '', '', 'mv_par04','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '05', 'Tipo ate ? ', '', '', 'mv_ch5', 'C',02, 0, 0, 'G', '', '' , '', '', 'mv_par05','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '06', 'Tipo de ? ? ', '', '', 'mv_ch6', 'C',02, 0, 0, 'G', '', '' , '', '', 'mv_par06','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '07', 'Estoque ate ? ', '', '', 'mv_ch7', 'C',01, 0, 0, 'G', '', '' , '', '', 'mv_par07','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '08', 'Estoque de ? ', '', '', 'mv_ch8', 'C',01, 0, 0, 'G', '', '' , '', '', 'mv_par08','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) u_PutSX1SN(cPerg, '09', 'Nome ? ', '', '', 'mv_ch9', 'C',90, 0, 0, 'G', '', '' , '', '', 'mv_par09','','','','','','','','','','','','','', '','','', aHelp[1][1], aHelp[1][2], aHelp[1][3]) RETURN // Alterado por Serpcom Tecnologia 03/2023 /*/ ??????????????????????????????????????? ??????????????????????????????????????? ??????????????????????????????????????? ??un??o ?GeraX1 ?Autor ?Microsiga ?Data ?13/02/09 ?? ??????????????????????????????????????? ??escri??o ?Verifica as perguntas inclu?do-as caso n?o existam ?? ?? ?Com tratamento para V10 ?? ??????????????????????????????????????? ??so ? ?? ??????????????????????????????????????? ??????????????????????????????????????? ??????????????????????????????????????? /*/ /* Static Function GeraX1(cPerg) LOCAL aArea := GetArea() LOCAL aRegs := {} LOCAL i := 0 LOCAL j := 0 LOCAL cPerg := PADR(cPerg, LEN(SX1->X1_GRUPO)) If ALLTRIM(cPerg) == "PESQNFE" AAdd(aRegs,{cPerg,"01","Data Entrada de ? ","","","mv_ch1","D",08,0,0,"G","","mv_par01","" , "", "","","","" ,"","","","","","","","","","","","","","","","","",""," ","", "","","","" }) AAdd(aRegs,{cPerg,"02","Data Entrada ate ? ","","","mv_ch2","D",08,0,0,"G","","mv_par02","" , "", "","","","" ,"","","","","","","","","","","","","","","","","",""," ","", "","","","" }) AADD(aRegs,{cPerg,"03","Serie de ? ","","","mv_ch3","C",03,0,0,"G","","mv_par03","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"04","Serie ate ? ","","","mv_ch4","C",03,0,0,"G","","mv_par04","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"05","Tipo ate ? ","","","mv_ch5","C",02,0,0,"G","","mv_par05","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"06","Tipo de ? ","","","mv_ch6","C",02,0,0,"G","","mv_par06","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"07","Estoque ate ? ","","","mv_ch7","C",01,0,0,"G","","mv_par07","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"08","Estoque de ? ","","","mv_ch8","C",01,0,0,"G","","mv_par08","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) AADD(aRegs,{cPerg,"09","Nome ? ","","","mv_ch9","C",90,0,0,"G","","mv_par09","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""}) EndIF dbSelectArea("SX1") dbSetOrder(1) For i:=1 to Len(aRegs) If !dbSeek(cPerg+aRegs[i,2]) RecLock("SX1",.T.) For j := 1 to FCount() If j <= Len(aRegs[i]) FieldPut(j,aRegs[i,j]) Endif Next // se tiver grupo de campo, ajusta tamanho da pergunta IF !empty(aRegs[i,40]) IF SXG->( DbSeek( PADR(aRegs[i,40],Len(SXG->XG_GRUPO)) ) ) SX1->X1_TAMANHO := SXG->XG_SIZE ENDIF ENDIF MsUnlock() Endif Next RestArea(aArea) Return() */ /* ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ±±ÉÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍ»±± ±±ºPrograma ³ GDToExcel º Autor ³ TOTVS RP º Data ³ 31/12/19 º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºDescricao ³ Exporta o Acols para Excel º±± ±±º ³ º±± ±±ÌÍÍÍÍÍÍÍÍÍÍØÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹±± ±±ºUso ³ PESQNFE º±± ±±ÈÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ±± ±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±± ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß */ Static Function GDToExcel(aHeader,aCols,cWorkSheet,cTable,lTotalize,lPicture) Local oFWMSExcel := FWMSExcel():New() Local oMsExcel Local aCells Local cType Local cColumn Local cFile Local cFileTMP Local cPicture Local lTotal Local nRow Local nRows Local nField Local nFields Local nAlign Local nFormat Local uCell DEFAULT cWorkSheet := "Nota de Entrada" DEFAULT cTable := cWorkSheet DEFAULT lTotalize := .T. DEFAULT lPicture := .F. BEGIN SEQUENCE oFWMSExcel:AddworkSheet(cWorkSheet) oFWMSExcel:AddTable(cWorkSheet,cTable) nFields := Len( aHeader ) For nField := 1 To nFields cType := aHeader[nField][8] nAlign := IF(cType=="C",1,IF(cType=="N",3,2)) nFormat := IF(cType=="D",4,IF(cType=="N",2,1)) cColumn := aHeader[nField][1] lTotal := ( lTotalize .and. cType == "N" ) oFWMSExcel:AddColumn(@cWorkSheet,@cTable,@cColumn,@nAlign,@nFormat,@lTotal) Next nField aCells := Array(nFields) nRows := Len( aCols ) For nRow := 1 To nRows For nField := 1 To nFields uCell := aCols[nRow][nField] IF ( lPicture ) cPicture := aHeader[nField][3] IF .NOT.( Empty(cPicture) ) uCell := Transform(uCell,cPicture) EndIF EndIF aCells[nField] := uCell Next nField oFWMSExcel:AddRow(@cWorkSheet,@cTable,aClone(aCells)) Next nRow oFWMSExcel:Activate() cFile := ( CriaTrab( NIL, .F. ) + ".xml" ) While File( cFile ) cFile := ( CriaTrab( NIL, .F. ) + ".xml" ) End While oFWMSExcel:GetXMLFile( cFile ) oFWMSExcel:DeActivate() IF .NOT.( File( cFile ) ) cFile := "" BREAK EndIF cFileTMP := ( GetTempPath() + cFile ) IF .NOT.( __CopyFile( cFile , cFileTMP ) ) fErase( cFile ) cFile := "" BREAK EndIF fErase( cFile ) cFile := cFileTMP IF .NOT.( File( cFile ) ) cFile := "" BREAK EndIF IF .NOT.( ApOleClient("MsExcel") ) BREAK EndIF oMsExcel := MsExcel():New() oMsExcel:WorkBooks:Open( cFile ) oMsExcel:SetVisible( .T. ) oMsExcel := oMsExcel:Destroy() END SEQUENCE oFWMSExcel := FreeObj( oFWMSExcel ) Return( cFile ) User Function grafico_teste(aSerie) Local oChart Local oDlg Local aRand := {} Local nItem := 0 //Cria a Janela DEFINE MSDIALOG oDlg PIXEL FROM 0,0 TO 400,600 //Instância a classe oChart := FWChartBar():New() //Inicializa pertencendo a janela oChart:Init(oDlg, .T., .T. ) //Seta o título do gráfico oChart:SetTitle("Títuloo", CONTROL_ALIGN_CENTER) //Adiciona as séries, com as descrições e valores for nItem:=1 to len(aSerie) oChart:addSerie("Ano 2011", 20044453.50) NEXT nItem //Define que a legenda será mostrada na esquerda oChart:setLegend( CONTROL_ALIGN_LEFT ) //Seta a máscara mostrada na régua oChart:cPicture := "@E 999,999,999,999,999.99" //Define as cores que serão utilizadas no gráfico aAdd(aRand, {"084,120,164", "007,013,017"}) //Seta as cores utilizadas oChart:oFWChartColor:aRandom := aRand oChart:oFWChartColor:SetColor("Random") //Constrói o gráfico oChart:Build() ACTIVATE MSDIALOG oDlg CENTERED Return