ALIAS HELP

variavel pag := 1

VARIAVEL #TEXTO_FONTE
   Private zFormVisita:='N', zFormCompleto:='N', zCabOs:='', zFgOsOpen:=(Select('HC_RETDI')>0), zOsNum:=if(zFgOsOpen,HC_RETDI->IdOs,0), ;
           zCodCli:=0, zRecnoOS:=0, zObsLines:=15, zQtdAnt:=9, zDesenhoDoForm:="", nRow:=0, znLines, zhRegOs

   dbCloseAll()
   ABRA("0NOIDX",r_siga,"HC_RETDI","HC_RETDI","HC_RETDI","IDOS")
   se .not. zFgOsOpen entao (DbGoBottom(),zOsNum:=Hc_RetDi->IdOs)
   
   if .not. QuickDialog("OS_Prt1", "Impressao de OS" ,{;
            {"Numero da OS:", "@zOsNum", @zOsNum, "999999", "", ""},;
            {"Form.Visita ?", "@zFormVisita", @zFormVisita, "!", "", ""},;
            {"Com Providencia?", "@zFormCompleto", @zFormCompleto, "!", "", ""} }) .or. .not. DbSeek(zOsNum)
      dbCloseAll()
      Return
   endif

   se zFormCompleto="S" entao (zObsLines:=25, zQtdAnt:=10)
   zCodCli := HC_RETDI->cr_cod_cli
   zRecnoOS := HC_RETDI->(Recno()) 

   dbCloseAll()
   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()))
   use ("mem:_oscli") new exclusive 
   DbSelectArea("HC_RETDI")
   if DbSeek( STR(zCodCli,6) )
      Mensagem("Selecionando OS do Cliente...")
      Do While .not. eof() .and. zCodCli=CR_COD_CLI .and. nRow<=10
         Mensagem("Solicitacoes anteriores: "+Str(nRow))
         se zOsNum<>HC_RETDI->IDOS entao _oscli->(zhRegOs:=Hc_RetDi->(Scatter()), AppendBlank(), Gather(zhRegOs), ++nRow)
         DbSkip()
     EndDo
     Mensagem("Processando...")
   endif
   _oscli->(DbCloseArea())
   HC_RETDI->(DbGoTo(zRecnoOS), zhRegOs := Scatter(), 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 BoxHalfPage
         oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-40 )
      .end_function
      .function BoxFullPage
         oPdf:Box( oPdf:pRow+1, 0, oPdf:sPrtLineLen, oPdf:nLinesPorPagina-1-(oPdf:pRow+1) )
      .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('Situacao;if(situacao=1,"Aberta",if(situacao=2,"Fechada","SolicFecha"));P;@S10;10;;')
   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:AddCol('DtFech;DATARET;D;;8;N;')
   // oLst:AddCol('HrFech;HORARET;C;xx:xx;5;;')
   // oLst:AddCol('Solucao;OBS_RETORN;C;@S30;30;;')
   // oLst:AddCol('cMt;COBS;N;999;  3;;')
   // oLst:AddCol('cRt;CRESULTADO;N;999;  3;;')

   // oLst:Cab1( "OS "+lTrim(Str(zOsNum,10))+", Em "+Dtoc(zhRegOs["DATA"])+" as "+zhRegOs["HORA"]+" hs" )
   oLst:Cab1( "OS "+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,6)+'- '+AllTrim (sccrcli->cr_nome), 'CNPJ/CPF: '+sccrcli->Cr_Cgc)
   oLst:AddCab( {"style"=>"size:12"}, 'Fantasia: '+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)
   oLst:AddCab( 'Endereco: '+sccrcli->(AllTrim(cr_rua)+' '+AllTrim(cr_bairro)+' '+AllTrim(cr_cep)) )
   oLst:AddCab( 'Email: '+AllTrim(sccrcli->cr_email),'Fax/Celular:'+AllTrim(sccrcli->Cr_fax))
   se !empty(sccrcli->cr_pontore) entao oLst:AddCab( 'Ponto Ref: '+AllTrim(sccrcli->cr_pontore) )
   oLst:AddCab( {"call_pdf_function"=>if(zFormCompleto="S","BoxFullPage","BoxHalfPage"), "style"=>"font:Helvetica-BoldOblique#size:08#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, zCabOs)
   se zFormCompleto<>"S" entao oLst:PrtD('')
      
   zhRegOs["CR_OBS"]:=AllTrim(zhRegOs["CR_OBS"])
   znLines := MlCount(zhRegOs["CR_OBS"], 130)
   nRow := 0
   do while ++nRow<=zObsLines
      se nRow <= znLines entao oLst:PrtD( {"style"=>"size:12"}, alltrim(Memoline(zhRegOs["CR_OBS"],130,nRow))) senao oLst:PrtD('')
   enddo
      
   if zFormCompleto="S" .and. (znLines := MlCount( (zhRegOs["SOLUCAO"]:=AllTrim(zhRegOs["SOLUCAO"])), 130)) > 0
      nRow := 0
      oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:9#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'PROVIDENCIAS')
      do while ++nRow <= znLines .and. nRow <= 10
         oLst:PrtD( alltrim(Memoline(zhRegOs["SOLUCAO"],130,nRow)))
      enddo
   endif

   nRow := 0
   if zFormVisita='S'
      oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:10#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'OBSERVACOES ADICIONAIS DO CLIENTE')
      do while ++nRow <= zQtdAnt
         oLst:PrtD('')
      enddo
      oLst:PrtD( {"style"=>"font:Helvetica-Oblique"}, "Ass.Cliente:__________________________________","Data/Hora:________________________")
   else
      oLst:PrtD( {"style"=>"font:Helvetica-BoldOblique#size:08#ncolor:99#width:80#bgfill:SombraEscuraComBorda", "COLS"=>"0,C"}, 'Ultimas Solicitacoes do Cliente')
      oLst:PrtD( {"style"=>"font:Courier-BoldOblique"}, '_CABCOLS_')
      do while .not. eof() .and. ++nRow <= zQtdAnt
         oLst:PrtD( '_DATACOLS_')
         DbSkip()
      enddo
   endif

   dbCloseAll()
   DbDrop('mem:_oscli')
#FIM_TEXTO_FONTE

//if zFormCompleto="S"
//   oLst:PrtD( {"style"=>"font:Helvetica-Oblique#row:(oPdf:nLinesPorPagina-6)"}, "________________________","________________________","________________________")
//   oLst:PrtD( {"style"=>"font:Helvetica-Oblique#row:(oPdf:nLinesPorPagina-5)"}, "Cliente                 ","Atendente               ","Suporte")
//   oLst:PrtD( {"style"=>"font:Helvetica-Oblique#row:(oPdf:nLinesPorPagina-3)"}, "TeamView: "+alltrim(SCCRCLI->cr_usuid), "SenhaTeamView: "+alltrim(SCCRCLI->cr_senha))
//endif

// 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:PrtD( {"style"=>"font:Helvetica-Oblique"}, " ","VALOR DOS PRODUTOS E SERVICOS: "+ Transform(m_fValProd,"@E 99,999,999,999.99") )
//xx oLst:PrtD( '_LINHA_GROSSA_')
//xx oLst:PrtD( {"call_pdf_function"=>"reposiciona_cursor"}, " ")
// oLst:PrtD( zTotMercadoria>0, {"style"=>"font:Helvetica-Oblique#col:40#row:(oPdf:nLinesPorPagina-6)"}, " ","VALOR DOS PRODUTOS: "+   Transform(zTotMercadoria ,"@E 99,999,999,999.99") )
// oLst:PrtD( zTotServicos >0,  {"style"=>"font:Helvetica-Oblique#col:30#row:(oPdf:pRow+1)"},            " ","VALOR DOS SERVICOS: "+   Transform(zTotServicos   ,"@E 99,999,999,999.99") )
// oLst:AddCab( {"COLS"=>"0,C"} ,{"style"=>"font:Helvetica-BoldOblique#bgfill:{1,{0.65,0.65,0.65},1}"}, 'Atendente:'+AllTrim(sf_vend->nome) )

// BLOCO_TXT zDesenhoDoForm
//    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)
//          .function xDesenhaForm
//            // :Box( nRow, nCol, nLargura, nAltura, nGrossuraLinha, aColor, nTypeBordaXpreenchimento)
//            oPdf:nFatorEspacamentoEntreLinhas := 1
//            oPdf:nFontSizeCorrente := 10
//            oPdf:Box(   5.4, 60, 35, 1, 3, {0.75, 0.75, 0.75} )
//            oPdf:Box(   5.4, 60, 35, 2 )
//            oPdf:Box( 15.35,  0, 95, 1, 3, {0.75, 0.75, 0.75} )
//            oPdf:Box( 17.35,  0, 95, 1, 3, {0.75, 0.75, 0.75} )
//            nRow := 1
//            do while nRow <= 32
//               oPdf:Box( nRow + 18.3, 0, 95, 1.1, 3, {0.95, 0.95, 0.95} )
//               nRow:=nRow+2
//            enddo
//            oPdf:Box( 15.35, 00, 95, 55 )
//            oPdf:Box( 51.4, 65, 20, 11.7, 3 , {0.75, 0.75, 0.75} )
//         .end_function
// FIM_BLOCO_TXT
// oLst:PrtLine( 'CONFIG', zDesenhoDoForm)
