ALIAS HELP

VARIAVEL zOsNum = 0
VARIAVEL zRecnoOS = 0
VARIAVEL zCodCli = 0
VARIAVEL nRow = 0
VARIAVEL znLines = 0
VARIAVEL zhRegOs = ""
variavel pag := 1
variavel zDesenhoDoForm := ""
variavel oProgressBar := ""

VARIAVEL #TEXTO_FONTE
   Private zFormularioParaVisita:='N', zCabOs:=''

   ABRA("0NOIDX", r_siga, "HC_RETDI", "HC_RETDI", "HC_RETDI", "IDOS")
   DbGoBottom()
   zOsNum:=HC_RETDI->IDOS
   if .not. QuickDialog("OS_Prt", "Vciga Informatica - Impressao de OS" ,{{"Numero da OS:", "@zOsNum", @zOsNum, "99999", "", ""},{"Form.Visita ?", "@zFormularioParaVisita", @zFormularioParaVisita, "!", "", ""} })
      HC_RETDI->(DbCloseArea())
      Return
   endif
   DbSeek(zOsNum)
   zRecnoOS := HC_RETDI->(Recno())
   zCodCli := HC_RETDI->CR_COD_CLI

   HC_RETDI->(DbCloseArea())
   ABRA("0NOIDX", r_siga, "HC_RETDI", "HC_RETDI", "HCRETCDC", "STR(cr_cod_cli,6) + Str(999999999-Val(Dtos(data)))")
   
   DbSeek( Str(zCodCli,6) )
   DbCreate("mem:_oscli",HC_RETDI->(DbStruct()))
   ABRA("0NOIDX", "", "mem:_oscli", "_oscli")
   DbSelectArea("HC_RETDI")
   if DbSeek( STR(zCodCli,6) )
      Mensagem("Selecionando OS do Cliente para atendimento...")
      Do While .not. eof() .and. zCodCli=CR_COD_CLI .and. nRow<=10
         Mensagem("Solicitacoes anteriores: "+Str(nRow))
         if zOsNum<>HC_RETDI->IDOS
            zhRegOs := Scatter()
            zhRegOs["CODIGO"] := HC_RETDI->(Recno())
            _oscli->( AppendBlank(), Gather(zhRegOs) )
            ++nRow
         endif
         DbSkip()
     EndDo
     Mensagem("Processando ARQUIVO ...")
   endif
   HC_RETDI->(DbGoTo(zRecnoOS), zhRegOs := Scatter(), DbCloseArea())
   _oscli->(DbCloseArea())

   Abra('0NOIDX',r_siga,'sf_vend', 'sf_vend')
   DbGoto( zhRegOs["FVENDEDOR"] )
   
   Abra('0NOIDX',r_siga,'vb_cobra', 'vb_cobra')
   DbGoto( zhRegOs["FVENDRETOR"] )

   Abra('0NOIDX',r_siga,'SCCRCLI', 'SCCRCLI')
   DbGoto( zhRegOs["CR_COD_CLI"] )
   
   zCabOs := "SOLICITACAO em "+Dtoc(zhRegOs["DATA"])+" as "+zhRegOs['HORA']+" hs - Atendimento: "+AllTrim(sf_vend->nome)
   debugalert('3 vai processar ')
      
      oLst:nLinesPorPagina := 66
      oLst:lPrtRodape := .f.
      oLst:lPortrait  := .t.

      BLOCO_TXT zDesenhoDoForm
         .function DesenhaForm
            oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-40 )
            // oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1-(oPdf:pRow+1 + 6) )
            // oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 0, oPdf:sPrtLineLen, 6)
            // oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 47, oPdf:sPrtLineLen-47, 6, 1, {0.95, 0.95, 0.95}, 3)
            // oPdf:Box( oPdf:pRow+1+ oPdf:nLinesPorPagina-1-(oPdf:pRow+1+6), 47, oPdf:sPrtLineLen-47, 6)
         .end_function

      FIM_BLOCO_TXT
      oLst:PrtLine( 'CONFIG', zDesenhoDoForm)

      oLst:cAlias_DataCols := 'os'
      oLst:cAliasMaster := 'os'

      Abra('0NOIDX','','mem:_oscli', '_oscli', '_oscli', '99999999-Val(Dtos(Data))')

      oLst:AddCol('Sit;if(situacao=2,"Fechada","Aberta");P;@S7;7;;')
      oLst:AddCol('DataLig;DATA;D;;8;N;')
      oLst:AddCol('Hora;HORA;C;xx:xx;5;N;')
      oLst:AddCol('Codig;IdOs;N;99999;5;N;')
      oLst:AddCol('Motivo_da_OS;Lower(alltrim(Memoline(CR_OBS,80,1))+" "+alltrim(Memoline(CR_OBS,80,2))+alltrim(Memoline(CR_OBS,80,3))+alltrim(Memoline(CR_OBS,80,4)));P;@S70;70;;')
     	  
      oLst:AddCab( {"AplicaFormatacaoDefaultNoCabecalho"=>"nao", "style"=>"font:Helvetica-Bold#size:14", "COLS"=>"0,C"}, "VCIGA INFORMÁTICA LTDA  F: 3034-3040/98852-8628 - OS Protocolo N°"+lTrim(Str(zOsNum,10)) )
      oLst:AddCab( {"style"=>"font:Helvetica-BoldOblique#size:9#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'CLIENTE SOLICITANTE')
      
      oLst:AddCab( {"style"=>"size:12"}, 'Nome: '+strzero(sccrcli->CR_COD_CLI,5)+' '+AllTrim (sccrcli->cr_nome), 'PJ/PF: '+sccrcli->Cr_Cgc)
      
      oLst:AddCab( {"style"=>"size:12"}, 'Fant.: '+AllTrim(sccrcli->cr_fantasi), 'Contato:'+AllTrim(sccrcli->cr_contato), 'Fone:'+AllTrim(sccrcli->cr_fone))
      oLst:AddCab( 'Cidade: '+ AllTrim(sccrcli->cr_cidade) + ' UF: ' + sccrcli->Cr_Uf,' INSC: '+AllTrim(sccrcli->Cr_insc_es))
      oLst:AddCab( 'End.:'+ AllTrim(sccrcli->cr_rua)+ ',N°' + sccrcli->Cr_NUMRUA + ' '+ sccrcli->cr_bairro+' '+sccrcli->cr_cep)
      oLst:AddCab( 'Email:'+AllTrim(sccrcli->cr_email),'Fone/Celular:'+AllTrim(sccrcli->Cr_fax))
      if !empty(sccrcli->cr_pontore)
         oLst:AddCab( 'Ponto Ref: '+AllTrim(sccrcli->cr_pontore) )
      endif
      oLst:AddCab( {"call_pdf_function"=>"DesenhaForm", "style"=>"font:Helvetica-BoldOblique#size:08#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, zCabOs)

      oLst:EvalLineBlocks('DETALHE', '')
      zhRegOs["CR_OBS"]:=AllTrim(zhRegOs["CR_OBS"])
      znLines := MlCount(zhRegOs["CR_OBS"], 130)
      nRow := 1
      do while nRow <= znLines .and. nRow<=14
         oLst:EvalLineBlocks('DETALHE', {"style"=>"size:12"}, alltrim(Memoline(zhRegOs["CR_OBS"],130,nRow)))
         nRow := nRow+1
      enddo
      do while nRow <= 12
         oLst:EvalLineBlocks('DETALHE', '')
         nRow := nRow+1
      enddo
      oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique"}, "Suporte:________________________","Resolvida?________________________")
      oLst:EvalLineBlocks('DETALHE', '')
      
      nRow := 1
      if zFormularioParaVisita='S'
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-BoldOblique#size:10#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'OBSERVACOES ADICIONAIS DO CLIENTE')
         do while nRow <= 9
            oLst:EvalLineBlocks('DETALHE', '')
            nRow := nRow+1
         enddo
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique"}, "Ass.Cliente:__________________________________","Data/Hora:________________________")
      else
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-BoldOblique#size:08#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'Ultimas Solicitacoes do Cliente')
         oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Courier-BoldOblique"}, '_CABCOLS_')
         do while .not. eof() .and. nRow <= 9
            oLst:EvalLineBlocks('DETALHE', '_DATACOLS_')
            DbSkip()
            nRow := nRow+1
         enddo
      endif

      sf_vend->(DbCloseArea())
      vb_cobra->(DbCloseArea())
      sccrcli->(DbCloseArea())
      _oscli->(DbCloseArea())
      DbDrop('mem:_oscli')
         
#FIM_TEXTO_FONTE

     // Fontes Padroes:
     // Courier               
     // Courier-Bold          negrito
     // Courier-Oblique       italico
     // Courier-BoldOblique   negrito italico
     // Helvetica             
     // Helvetica-Bold        negrito
     // Helvetica-Oblique     italico
     // Helvetica-BoldOblique negrito italico
            // oPdf:Box( nRow, nCol, nLarguraDoBox, nAlturaDoBox, nGrossuraLinha, aColor, nTypeBordaXpreenchimento )
            //           nTypeBordaXpreenchimento: 1-So_Contorno    2-Preenche_Interior   3-Contorno_e_interior
            //           aColor: {0,0,0} Preto...  {1,1,1} Branco     {.50,.50,.50} Cinza ...  quanto mais proximo do 1 mais branco fica
            // oPdf:sPrtLineLen = largura maxima da linha mais comprida do relatorio
            // oPdf:nLinesPorPagina = quantidade de linhas que vou querer por pagina

            // oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1, 1, {0.95, 0.95, 0.95}, 2)
            // oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1)

            // oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina - 1 )
            // oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1)
            // oPdf:Say( 3.1, 10, "eduardo", "Helvetica-BoldOblique")
            //oPdf:Box( 0, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina )

      //xx oLst:EvalLineBlocks('DETALHE', {"style"=>"font:Helvetica-Oblique"}, " ","VALOR DOS PRODUTOS E SERVICOS: "+ Transform(m_fValProd,"@E 99,999,999,999.99") )
      //xx oLst:EvalLineBlocks('DETALHE', '_LINHA_GROSSA_')
      //xx oLst:EvalLineBlocks('DETALHE', {"call_pdf_function"=>"reposiciona_cursor"}, " ")
      // oLst:EvalLineBlocks('DETALHE', zTotMercadoria>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","VALOR DOS PRODUTOS: "+   Transform(zTotMercadoria ,"@E 99,999,999,999.99") )
      // oLst:EvalLineBlocks('DETALHE', zTotServicos >0,  {"style"=>"font:Helvetica-Oblique#col:30#row:(oPdf:pRow+1)"},            " ","VALOR DOS SERVICOS: "+   Transform(zTotServicos   ,"@E 99,999,999,999.99") )
