#Include 'Protheus.ch' User Function AgreFiltra() Local oFont22 := TFont():New("Arial",,22,.T.) Local oFont20 := TFont():New("Arial",,20,.T.) Local oFont12 := TFont():New("Arial",,15,.T.) Local oSay1,oSay2,oSay3,oSay4, oSay5 Local oGet1,oGet2,oGet3,oGet4, oGet5 Local aItems := {'','CIF','FOB'} Private cGet1,cGet2, cGet6 := "" Private dGet3 := CtoD(Space(08)) Private dGet4 := CtoD(Space(08)) Private dGet5 := Space(02) Private cUser := AllTrim(RetCodUsr())//Retorna o código do Usuário Private oButton1,oButton2,oButton3,oButton4,oButton5 Private cCrLf := Chr(13) + Chr(10) Private oCombo, cCombo DEFINE MSDIALOG oDlg FROM 0,0 TO 400,633 PIXEL TITLE 'Faturamento Preço Médio' TGroup():New(005,005,60,315,'Agregadores',oDlg,CLR_HBLUE,,.T.) oCheck1 := TCheckBox():New(014,010,'Região Estratégica',,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oCheck1 := TCheckBox():New(014,230,'Vendedor ',,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oCheck2 := TCheckBox():New(027,010,'Categoria' ,,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oCheck3 := TCheckBox():New(027,230,'Unid. Negocio' ,,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oCheck2 := TCheckBox():New(042,010,'Estado' ,,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oCheck3 := TCheckBox():New(042,230,'CIF x FOB' ,,oDlg, 100,210,,,oFont12,,,,,.T.,,,) oSay1:= tSay():New(64,010,{||"Data Inicial:"},oDlg,,oFont12,,,,.T.,CLR_BLUE,CLR_RED,50,15) oGet1:= TGet():New(64,045,{|u| if(PCount()>0,dGet3:=u,dGet3) } , oDlg, 80,10,"@!",,,,,,,.T.,,,,,,,,,,"dGet3") oSay2:= tSay():New(64,200,{||"Data Final:"},oDlg,,oFont12,,,,.T.,CLR_BLUE,CLR_RED,50,15) oGet2:= TGet():New(64,230,{|u| if(PCount()>0,dGet4:=u,dGet4) } , oDlg, 80,10,"@!",,,,,,,.T.,,,,,,,,,,"dGet4") oSay2:= tSay():New(78,010,{||"Uni. Negoc:"},oDlg,,oFont12,,,,.T.,CLR_BLUE,CLR_RED,50,15) oGet2:= TGet():New(78,045,{|u| if(PCount()>0,cGet2:=u,cGet2) } , oDlg, 80,10,"@!",,,,,,,.T.,,,,,,,,,,"cGet2") oSay3:= tSay():New(78,200,{||"CIF x FOB: "},oDlg,,oFont12,,,,.T.,CLR_BLUE,CLR_RED,50,15) oCombo:= tComboBox():New(78,230,{|u|if(PCount()>0,cCombo:=u,cCombo)}, aItems,80,10,oDlg,,,,,,.T.,,,,,,,,,'cCombo') oSay4:= tSay():New(92,010,{||"Vendedores:"},oDlg,,oFont12,,,,.T.,CLR_BLUE,CLR_RED,50,10) oGet6:= TGet():New(92,045,{|u| if(PCount()>0,cGet6:=u,cGet6) } , oDlg, 70,10,"@!",,,,,,,.T.,,,,,,,,,,"cGet6") oButton2:=tButton():New(92,116,"&...",oDlg,{||Processa({||U_TestSelec()},"Aguarde...","Processando...")},9,10,,,,.T.) oget6 := oButton2 oButton1:=tButton():New(390,270,"&Imprimir",oDlg,{||Processa({||FProcREG1(oDlg)},"Aguarde...","Processando...")},40,10,,,,.T.) ACTIVATE MSDIALOG oDlg CENTERED Return Static Function FProcREG1(oDlgUm) Local oReport //Fecha dialog oDlgUm:End() //If TRepInUse() // Pergunte("MT00000003",.F.) // oReport := ReportDef() // oReport:PrintDialog() //EndIf Return Static Function ReportDef() Local oReport Local oSection Local oBreak Local sTitulo := "Relatório Faturamento - Período de " + dtoc(mv_par01) + ' a ' + dtoc(mv_par02) oReport := TReport():New("FatOvos", sTitulo ,"MT00000003",{|oReport| PrintReport(oReport)},"Relatório Faturamento") oSection := TRSection():New(oReport,"Relatório Faturamento",{"Z16"}) TRCell():New(oSection,"Z16_DATA","Z16") TRCell():New(oSection,"Z16_NF","Z16") Return oReport Static Function PrintReport(oReport) Local oSection := oReport:Section(1) Local cPart Local cFiltro #IFDEF TOP MakeSqlExpr("MT00000003") oSection:BeginQuery() BeginSql alias "QRYZ16" SELECT * FROM %table:Z16% Z16 CONVERT(VARCHAR, Z16_DATA, 112) BETWEEN convert(varchar, %Exp:MV_PAR01%, 112) AND convert(varchar, %Exp:MV_PAR02%, 112) EndSql oSection:EndQuery(mv_par04) #ELSE MakeAdvplExpr("MT00000003") #ENDIF oSection:Print() Return Static Function Vendedor() Local _stru:={} Local aCpoBro := {} Local oDlgLocal aCores := {} Private lInverte := .F. Private cMark := GetMark() Private oMark //Cria um arquivo de Apoio AADD(_stru,{"OK" ,"C" ,2 ,0 }) AADD(_stru,{"COD" ,"C" ,6 ,0 }) AADD(_stru,{"NOME" ,"C" ,30 ,0 }) AADD(_stru,{"NOMERE" ,"C" ,30 ,0 }) cArq:=Criatrab(_stru,.T.) DBUSEAREA(.t.,,carq,"TTRB") //Alimenta o arquivo de apoio com os registros do cadastro de clientes (SA3) DbSelectArea("SA3") DbGotop() While SA3->(!Eof()) DbSelectArea("TTRB") RecLock("TTRB",.T.) TTRB->COD := SA3->A3_COD TTRB->NOME := SA3->A3_LOJA TTRB->NOMERE := SA3->A3_NOME MsunLock() SA3->(DbSkip()) Enddo //Define quais colunas (campos da TTRB) serao exibidas na MsSelect aCpoBro := {{ "OK" ,, "Mark" ,"@!"},; { "COD" ,, "Codigo" ,"@!"},; { "NOME" ,, "Loja" ,"@!"},; { "NOMERE" ,, "Nome Red" ,"@!"}} //Cria uma Dialog DEFINE MSDIALOG oDlg TITLE "MarkBrowse c/Refresh" From 9,0 To 315,800 PIXEL DbSelectArea("TTRB") DbGotop() //Cria a MsSelect oMark := MsSelect():New("TTRB","OK","",aCpoBro,@lInverte,@cMark,{17,1,150,400},,,,,) oMark:bMark := {| | Disp()} //Exibe a Dialog ACTIVATE MSDIALOG oDlg CENTERED ON INIT EnchoiceBar(oDlg,{|| oDlg:End()},{|| oDlg:End()}) //Fecha a Area e elimina os arquivos de apoio criados em disco. TTRB->(DbCloseArea()) Iif(File(cArq + GetDBExtension()),FErase(cArq + GetDBExtension()) ,Nil) Return