Вы находитесь на странице: 1из 3

User Function IMPMON()

//////////////////////////////////////////////
//Declaracao de variaveis
//////////////////////////////////////////////
Private oReport := Nil
Private oSecCab := Nil
Private cPerg := PadR ("IMPMON", Len (SX1->X1_GRUPO))
//////////////////////////////////////////////
//Criacao e apresentacao das perguntas �
//////////////////////////////////////////////
PutSx1(cPerg,"01","Da Emissao ?"
, ��, ��, " mv_ch1","D",8,0,0,"G","","","","S","MV_PAR01","","","","","","","","","",""
,"","","","","","","","","")
PutSx1(cPerg,"02","Ate a
Emissao ?", ��, ��, " mv_ch2","D",8,0,0,"G","","","","S","MV_PAR02","","","","","","","
","","","","","","","","","","","","")
PutSx1(cPerg,"03","Frota de?" , ��, ��, " mv_ch3","C",TamSx3 ("DA3_COD")[1] ,
0,,"G","","DA302","","","mv_par03","","","","","","","","","","","","","","","","")
PutSx1(cPerg,"04","Frota ate?" , ��, ��, " mv_ch4","C",TamSx3 ("DA3_COD")[1] ,
0,,"G","","DA302","","","mv_par04","","","","","","","","","","","","","","","","")

//////////////////////////////////////////////
//Definicoes/preparacao para impressao �
//////////////////////////////////////////////
ReportDef()
oReport:PrintDialog()

Return Nil

/*
��������������������������������������������������������
��������������������������������������������������������
������������������������������������������������
�������������������������ͻ��
���Programa �IMPMON �Autor � Leandro Trevizan � Data � 21/02/2018 ���
������������������������������������������������
��������������������������� ͹� �
���Desc. � Defini��o da estrutura do relat�rio. ���
��� � ���
������������������������������������������������
��������������������������� ͹� �
���Uso � ���
������������������������������������������������
�������������������������ͼ��
������������������������������������������������
�����������������������������
������������������������������������������������
�����������������������������
*/
Static Function ReportDef()
Local oSection1
Local oBreak

oReport := TReport():New("IMPMON","Rela��o das Notas Monitoradas",cPerg,{|


oReport| PrintReport(oReport)},"Impress�o das Notas Monitoradas.")
oReport:SetLandscape(.T.)
oSecCab := TRSection():New( oReport , "Notas Monitoradas", {"QRY"} )
//TRCell():New( oSecCab, "FILIAL" , "QRY","FILIAL","@!",10)
TRCell():New( oSecCab, "EMISSAO" , "QRY","DATA_EMISSAO")
TRCell():New( oSecCab, "CLIENTE" , "QRY","CLIENTE","@!",8)
TRCell():New( oSecCab, "LOJA" , "QRY","LOJA","@!",4)
TRCell():New( oSecCab, "NOME" , "QRY","NOME","@!",40)
TRCell():New( oSecCab, "FROTA" , "QRY","FROTA","@!",6)
TRCell():New( oSecCab, "MOTORI" , "QRY","MOTORISTA","@!",30)
TRCell():New( oSecCab, "NOTA" , "QRY","NOTA","@!",9)
TRCell():New( oSecCab, "SERIE" , "QRY","SERIE","@!",5)
TRCell():New( oSecCab, "PEDIDO" , "QRY","PEDIDO","@!",6)
//TRCell():New( oSecCab, "FROTA" , "QRY","FROTA","@!",6)
//TRCell():New( oSecCab, "CLIENTE" , "QRY","CLIENTE","@!",6)
//TRCell():New( oSecCab, "LOJA" , "QRY","LOJA","@!",2)

//TRCell():New( oSecCab, "PLACA" , "QRY","PLACA","@!",10)


//TRCell():New( oSecCab, "MOTORI" , "QRY","MOTORI","@!",30)
//TRCell():New( oSecCab, "ENDERECO" , "QRY","ENDERECO","@!",30)
//TRCell():New( oSecCab, "CIDADE" , "QRY","CIDADE","@!",30)
//TRCell():New( oSecCab, "CEP" , "QRY","CEP","@!",10)
//TRCell():New( oSecCab, "MENSAGEM" , "QRY","MENSAGEM","@!",30)
TRCell():New( oSecCab, "STATUS" , "QRY","STATUS","@!",20)
TRCell():New( oSecCab, "ZDA_QUANT" , "QRY","QUANTIDADE","@E
999,999,999.99",20)
TRCell():New( oSecCab, "MOTIVO" , "QRY","MOTIVO","@!",150)

oBreak := TRBreak():New(oSecCab,oSecCab:Cell("FROTA"),"FROTA")

TRFunction():New(oSecCab:Cell("ZDA_QUANT"),/*cId*/,"COUNT"
,/*oBreak*/,"QUANTIDADE DE NOTAS",/*cPicture*/,/*uFormula*/,.F. ,.T.
,.F. ,oSecCab)

Return Nil

/*
������������������������������������������������
�����������������������������
������������������������������������������������
�����������������������������
������������������������������������������������
�������������������������ͻ��
���Programa �IMPMON �Autor � Leandro Trevizan � Data � 03/08/2017 ���
������������������������������������������������
��������������������������� ͹� �
���Desc. � ���
��� � ���
������������������������������������������������
��������������������������� ͹� �
���Uso � ���
������������������������������������������������
�������������������������ͼ��
������������������������������������������������
�����������������������������
������������������������������������������������
�����������������������������
*/
Static Function PrintReport(oReport)
Local cQuery := ""

Pergunte(cPerg,.F.)

TCSQLExec("alter session set NLS_DATE_FORMAT=�dd/mm/yyyy�")

cQuery += " SELECT " + CRLF


cQuery += " ZDA.ZDA_NOTA NOTA" + CRLF
cQuery += " ,ZDA.ZDA_SERIE SERIE" + CRLF
cQuery += " ,CASE WHEN ZDA.ZDA_FILIAL = �07� THEN �GUARA� WHEN ZDA.ZDA_FILIAL
= �10� THEN �ICEM� WHEN ZDA.ZDA_FILIAL = �16� THEN �ICEM BR 153� ELSE
ZDA.ZDA_FILIAL END FILIAL " + CRLF
cQuery += " ,CASE WHEN ZDA.ZDA_STATUS = �1� THEN �NOTA EMITIDA� WHEN
ZDA.ZDA_STATUS = �2� THEN �NOTA CANCELADA� WHEN ZDA.ZDA_STATUS = �3� THEN
�CONFERENCIA REALIZADA� END STATUS " + CRLF
cQuery += " ,ZDA.ZDA_CLIENT CLIENTE " + CRLF
cQuery += " ,ZDA.ZDA_LOJA LOJA " + CRLF
cQuery += " ,to_date(ZDA_DATA,�RRRRMMDD�) EMISSAO " + CRLF
cQuery += " ,ZDA.ZDA_NOME NOME " + CRLF
cQuery += " ,ZDA.ZDA_FROTA FROTA " + CRLF
cQuery += " ,ZDA.ZDA_PLACA PLACA " + CRLF
cQuery += " ,ZDA.ZDA_MOTORI MOTORI " + CRLF
cQuery += " ,ZDA.ZDA_MENNOT MENSAGEM " + CRLF
cQuery += " ,ZDA.ZDA_PEDIDO PEDIDO " + CRLF
cQuery += " ,ZDA.ZDA_END ENDERECO " + CRLF
cQuery += " ,ZDA.ZDA_CIDADE CIDADE " + CRLF
cQuery += " ,ZDA.ZDA_CEP CEP " + CRLF
cQuery += " ,ZDA_QUANT " + CRLF
cQuery += " ,ZDA.ZDA_MOTIVO MOTIVO " + CRLF
cQuery += " FROM " + RetSqlName("ZDA") + " ZDA " + CRLF
cQuery += " WHERE ZDA_DATA BETWEEN �" + dtos(mv_par01) + "� AND �" +
dtos(mv_par02) + "� " + CRLF
cQuery += " AND ZDA_FILIAL = �" + xFilial("ZDA") + "� " +CRLF
cQuery += " AND ZDA_FROTA BETWEEN �" + mv_par03 + "� AND �" + mv_par04 + "� "
+ CRLF
cQuery += " AND ZDA.D_E_L_E_T_ <> �*� " + CRLF
cQuery += " ORDER BY ZDA_FROTA,ZDA_CLIENT,ZDA_LOJA,ZDA.ZDA_NOTA,ZDA.ZDA_SERIE " +
CRLF
cQuery := ChangeQuery(cQuery)

If Select("QRY") > 0
Dbselectarea("QRY")
QRY->(DbClosearea())
EndIf

TcQuery cQuery New Alias "QRY"

oSecCab:BeginQuery()
oSecCab:EndQuery({{"QRY"},cQuery})
oSecCab:Print()

Return Nil

Оценить