ALIAS HELP
VARIAVEL #TEXTO_FONTE
   Private zaLines:={},zDe:=CtoD('01'+SubStr(Dtoc(Date()),3)),zAte:=Date(),zCpf:=Space(11), zDias, oProgBar, zCmdsDurante, ZSoConfirmados:="S"
   aAdd( zaLines, {"Data Inicial...:", "@zDe", @zDe, "99.99.9999", "", ""})
   aAdd( zaLines, {"Data Final.....:", "@zAte", @zAte, "99.99.9999", "", ""})
   aAdd( zaLines, {"CPF Paciente...:", "@zCpf", @zCpf, "99999999999", "", ""})
   aAdd( zaLines, {"So Confirmados ?", "@ZSoConfirmados", @ZSoConfirmados, "99999999999", "", ""})
   if .not. QuickDialog("Lst_fPopPosV", "Parametros", zaLines)
      Return
   endif

   dbCloseAll()
   SetAliasAaMm(zAte)
   Abra( '0NOIDX', r_siga, WSE_PSIM, 'se_psim', Wse_psim_p, 'fnumped')
   Abra ('0NOIDX', r_siga, 'vb_fpop', 'vb_fpop')
   //oProgBar:=myProgressBar():Create('Selecionando recompras previstas do periodo...')
   //xDbCopyTo('mem:_fpop', 'fpop', {||oProgBar:Step(), mqatend>0.And.FCONFIRMAD='S'.And.(val(zCpf)=0.or.val(zCpf)=val(CPF)).And.FDATAEMI>=zDe.AND.FDATAEMI<=zAte})
   //oProgBar:Close()
   xDbCopyTo('mem:_fpop', 'fpop', {||mqatend>0.And.FCONFIRMAD='S'.And.(val(zCpf)=0.or.val(zCpf)=val(CPF)).And.FDATAEMI>=zDe.AND.FDATAEMI<=zAte})
   dbCloseAll()

   Abra ('0NOIDX', r_Siga, wSe_Psim, 'se_psim', wse_psim_p+'dr', 'str(pcod,10)+Dtos(mData)+Paciente')
   Abra ('0NOIDX', r_siga, 'vb_pac',  'vb_pac',  'vb_pac',   'paciente')
   Abra ('0NOIDX', r_siga, 'se_prod', 'se_prod', 'seip_dc6', 'pdic6')
   
   Use ('mem:_fpop') new exclusive
   Index On PACIENTE+Dtos(FDATAEMI) to ('mem:_fpop')
   DbGoTop()

   oLst:Cab1( "VENDAS CONFIRMADAS FARMACIA POPULAR")
   oLst:Cab2( "Periodo "+Dtoc(zDe)+" a "+Dtoc(zAte), "Emitida em "+dtoc(date())+" as "+time()+" hs" )
  
   oLst:AddCab( '_LINHA_FINA_' )
   oLst:AddCab( '_CABCOLS_' )
   oLst:AddCab( '_LINHA_GROSSA_' )

   oLst:cAlias_DataCols := 'line1'

   oLst:AddCol('Pedido;fnumped;N;99999999;8;;')
   oLst:AddCol('DtCompr;fDataEmi;D;99.99.9999;10;;')
   oLst:AddCol('DtRecomp;(FDATAEMI+mqatend*APLICACOES/if(POSOLOGIA>0,POSOLOGIA,1));P;99.99.9999;10;;')
   oLst:AddCol('Paciente;Paciente;C;@S25;25;;')
   oLst:AddCol('CPF;FormataCnpjCpf(cpf);P;@S14;14;;')
   oLst:AddCol('Autorizacao;Autoriza;C;@S15;15;;')
   oLst:AddCol('Vl.Subsidio;psubsidio*mqatend;P;@E 99999,999.99;12;;;Direita;Some;')                                                  // Col 3
   oLst:AddCol('Medicamento;Se_Prod->( DbSeek(_fpop->pDic6), pDesc );P;@S30;30;;')
   oLst:AddCol('Unids;mqatend;N;9999;5;;')
   oLst:AddCol('Posol;POSOLOGIA;N;999;5;;')
   oLst:AddCol('Aplic;(APLICACOES*mqatend);P;999;3;;')
   // oLst:AddCol('DtReceit;se_psim->mDataRecei;P;99.99.9999;10;;')
   // oLst:AddCol('Medico;se_psim->medico;P;@S30;30;;')
   // oLst:AddCol('Crm;se_psim->crm;P;@S10;10;;')

   oLst:AddRodape( '_LINHA_FINA_', "", {|| "Pagina "+Str(++pag,4)+" / ####"} )
   
   oLst:DbEval()
   oLst:lFecharGruposAbertos := .t.
   oLst:SetFormatSomaCol(4, {||"** TOTAIS GERAIS "}, .t. /*Alterar Descricao do Totalizador Global*/)
   oLst:PrtD( '_LINHA_GROSSA_' )
   oLst:PrtD( {"style"=>"font:Courier-BoldOblique"}, '_SOMACOLS_GLOBAL_' )

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