/**
  * Define os dados dos documentos válidos
  *
  * @param \Doctrine\DBAL\Statement $oStatement
  * @param  array                   $aParametros
  * @throws Exception
  */
 public function setDadosDocumentosValidos(Doctrine\DBAL\Statement $oStatement, array $aParametros)
 {
     // Notas Válidas
     $this->SetFont('Arial', 'B', 8);
     $this->SetFillColor(201, 201, 201);
     $this->Cell(0, 5, utf8_decode('LANÇAMENTOS VÁLIDOS'), 1, 1, 'C', TRUE);
     $this->Ln(1);
     $aLarguraCelulas = array(6, 13, 10, 50, 25, 9, 12, 20, 20, 27, 85);
     $this->SetFillColor(230, 230, 230);
     $this->Cell($aLarguraCelulas[0], 5, utf8_decode('Dia'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[1], 5, utf8_decode('Número'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[2], 5, utf8_decode('Série'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[3], 5, utf8_decode('Tipo'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[4], 5, utf8_decode('Situação'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[5], 5, utf8_decode('Cod.'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[6], 5, utf8_decode('Aliq.(%)'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[7], 5, utf8_decode('Base(R$)'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[8], 5, utf8_decode('ISS(R$)'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[9], 5, utf8_decode('CNPJ Tomador'), 1, NULL, NULL, TRUE);
     $this->Cell($aLarguraCelulas[10], 5, utf8_decode('Razão Tomador'), 1, NULL, NULL, TRUE);
     $this->SetFont('Arial', NULL, 8);
     try {
         $oStatement->execute($aParametros);
         if ($oStatement->rowCount() > 0) {
             $fTotalBase = 0;
             $fTotalIss = 0;
             while ($aNota = $oStatement->fetch()) {
                 $sDiaEmissaoDocumento = substr($aNota['documento_data'], -2);
                 $this->Ln();
                 $this->Cell($aLarguraCelulas[0], 5, $sDiaEmissaoDocumento, 1, 0, 'C');
                 $this->Cell($aLarguraCelulas[1], 5, $aNota['documento_numero'], 1, 0, 'R');
                 $this->Cell($aLarguraCelulas[2], 5, $aNota['documento_serie'], 1, 0, 'R');
                 // Tipo de documento
                 if ($aNota['documento_classe'] == 'nfse') {
                     $sTipoNota = 'NFSe';
                     if ($aNota['documento_tipo']) {
                         $oTipoNota = Administrativo_Model_ParametroPrefeituraRps::getByTipoEcidade($aNota['documento_tipo']);
                         $sTipoNota = $oTipoNota->getTipoNfseDescricao();
                     }
                     $this->Cell($aLarguraCelulas[3], 5, utf8_decode($sTipoNota), 1);
                 } else {
                     if ($aNota['documento_classe'] == 'dms' && $aNota['documento_tipo']) {
                         if ($aNota['documento_tipo_descricao']) {
                             $sTipoNota = $aNota['documento_tipo_descricao'];
                         } else {
                             $oTipoNota = Administrativo_Model_ParametroPrefeituraRps::getByTipoEcidade($aNota['documento_tipo']);
                             $sTipoNota = $oTipoNota->getTipoNfseDescricao();
                         }
                         $this->Cell($aLarguraCelulas[3], 5, utf8_decode($sTipoNota), 1);
                     } else {
                         $this->Cell($aLarguraCelulas[3], 5, '-', 1);
                     }
                 }
                 // Formata dados
                 $sServicoValorAliquota = DBSeller_Helper_Number_Format::toMoney($aNota['servico_valor_aliquota']);
                 $sServicoValorBaseCalculo = DBSeller_Helper_Number_Format::toMoney($aNota['servico_valor_base_calculo']);
                 $sServicoValorIss = DBSeller_Helper_Number_Format::toMoney($aNota['servico_valor_iss']);
                 $sTomadorCnpjCpf = DBSeller_Helper_Number_Format::maskCPF_CNPJ($aNota['tomador_cnpjcpf']);
                 $sTomadorRazaoSocial = utf8_decode($aNota['tomador_razao_social']);
                 $sTomadorRazaoSocial = substr($sTomadorRazaoSocial, 0, 50);
                 // Verifica se é tomador não identificado
                 if (!$sTomadorCnpjCpf) {
                     $sTomadorRazaoSocial = utf8_decode('Não identificado');
                 }
                 // Trata a situação do documento
                 switch (strtoupper($aNota['documento_situacao'])) {
                     case 'T':
                         $sSituacaoDocumento = utf8_decode('Tributado');
                         break;
                     case 'R':
                         $sSituacaoDocumento = utf8_decode('Retido');
                         break;
                     case 'IS':
                         $sSituacaoDocumento = utf8_decode('Isento');
                         break;
                     case 'E':
                         $sSituacaoDocumento = utf8_decode('Extraviado');
                         break;
                     default:
                         $sSituacaoDocumento = '-';
                 }
                 // ALtera a situação do documento quando a natureza for fora do município
                 if ($aNota['documento_natureza_operacao'] == 2) {
                     $sSituacaoDocumento = utf8_decode('Fora do Município');
                 }
                 // Nota cancelada
                 if ($aNota['documento_status_cancelamento'] == 't' || $aNota['documento_situacao'] == 'c') {
                     $sSituacaoDocumento = utf8_decode('Cancelado');
                     $sServicoValorBaseCalculo = '-';
                     $sServicoValorIss = '-';
                 }
                 // Nota substituida
                 if (!empty($aNota['documento_id_nota_substituta'])) {
                     $sSituacaoDocumento = utf8_decode('Substituida');
                     $sServicoValorBaseCalculo = '-';
                     $sServicoValorIss = '-';
                 }
                 // Verifica se a nota foi substituida ou cancelada não soma os valores totais
                 if ($aNota['documento_status_cancelamento'] != 't' && empty($aNota['documento_id_nota_substituta'])) {
                     $fTotalBase += $aNota['servico_valor_base_calculo'];
                     $fTotalIss += $aNota['servico_valor_iss'];
                 }
                 $this->Cell($aLarguraCelulas[4], 5, $sSituacaoDocumento, 1, 0, 'L', NULL);
                 $this->Cell($aLarguraCelulas[5], 5, $aNota['servico_item_lista_servico'], 1, 0, 'L', NULL);
                 $this->Cell($aLarguraCelulas[6], 5, $sServicoValorAliquota, 1, 0, 'R', NULL);
                 $this->Cell($aLarguraCelulas[7], 5, $sServicoValorBaseCalculo, 1, 0, 'R', NULL);
                 $this->Cell($aLarguraCelulas[8], 5, $sServicoValorIss, 1, 0, 'R', NULL);
                 $this->Cell($aLarguraCelulas[9], 5, $sTomadorCnpjCpf, 1, 0, 'L', NULL);
                 $this->Cell($aLarguraCelulas[10], 5, $sTomadorRazaoSocial, 1, 0, 'L', NULL);
             }
             $this->SetFont('Arial', 'B', 8);
             $this->Ln();
             $this->Cell(113);
             $this->Cell($aLarguraCelulas[6], 5, 'Total:', 1);
             $this->Cell($aLarguraCelulas[7], 5, DBSeller_Helper_Number_Format::toMoney($fTotalBase), 1, 0, 'R');
             $this->Cell($aLarguraCelulas[8], 5, DBSeller_Helper_Number_Format::toMoney($fTotalIss), 1, 0, 'R');
         } else {
             $this->Ln();
             $this->Cell(0, 5, utf8_decode('Sem Lançamentos no Período'), 1, NULL, 'C');
         }
         $oStatement->closeCursor();
     } catch (Exception $oErro) {
         throw new Exception($oErro->getMessage());
     }
 }