/**
  * 
  */
 public function pesquisarAction()
 {
     $comprovanteParamentoModel = new ComprovantePagamento();
     $this->view->comprovantes = $comprovanteParamentoModel->pesquisarComprovantePorItem($this->getRequest()->getParam('item'));
     array_walk($this->view->comprovantes, function (&$value) {
         $value = array_map('utf8_encode', $value);
     });
 }
 /**
  * 
  */
 public function comprovacaopagamentoAction()
 {
     $this->verificarPermissaoAcesso(false, true, false);
     $idPlanilhaAprovacao = $this->getRequest()->getParam('idPlanilhaAprovacao');
     $planilhaItemModel = new PlanilhaItem();
     $produtoModel = new Produto();
     $etapaModel = new PlanilhaEtapa();
     $itemModel = new PlanilhaItem();
     $itemPlanilhaAprovacao = $planilhaItemModel->pesquisar($idPlanilhaAprovacao);
     $produto = $produtoModel->find($itemPlanilhaAprovacao->idProduto)->current();
     $etapa = $etapaModel->find($itemPlanilhaAprovacao->idEtapa)->current();
     $item = $itemModel->find($itemPlanilhaAprovacao->idPlanilhaItem)->current();
     $fornecedorModel = new FornecedorModel();
     $fornecedor = $fornecedorModel->pesquisarFornecedorItem($idPlanilhaAprovacao);
     if ($fornecedor) {
         $fornecedor = (object) array_map('utf8_encode', $fornecedor);
         $cpfCnpj = $fornecedor->CNPJCPF;
         $fornecedorUsaCnpj = 14 == strlen($cpfCnpj);
         $fornecedor->CNPJCPF = $fornecedorUsaCnpj ? Mascara::addMaskCNPJ($cpfCnpj) : Mascara::addMaskCPF($cpfCnpj);
         $fornecedor->usaCnpj = $fornecedorUsaCnpj;
         $this->view->fornecedor = $fornecedor;
     }
     $comprovanteParamentoModel = new ComprovantePagamento();
     $comprovantesDePagamento = $comprovanteParamentoModel->pesquisarComprovantePorItem($idPlanilhaAprovacao);
     array_walk($comprovantesDePagamento, function (&$comprovanteDePagamento) use($fornecedorModel) {
         $comprovanteDePagamento = (object) $comprovanteDePagamento;
         $fornecedor = $fornecedorModel->find($comprovanteDePagamento->idFornecedor)->current();
         if ($fornecedor) {
             $cpfCnpj = $fornecedor->CNPJCPF;
             $fornecedorUsaCnpj = 14 == strlen($cpfCnpj);
             $fornecedor->CNPJCPF = $fornecedorUsaCnpj ? Mascara::addMaskCNPJ($cpfCnpj) : Mascara::addMaskCPF($cpfCnpj);
         } else {
             $fornecedor = new stdClass();
             $fornecedor->CNPJCPF = '';
         }
         $comprovanteDePagamento->fornecedor = $fornecedor;
         unset($comprovanteDePagamento->idFornecedor);
     });
     $pais = new Pais();
     $paises = $pais->buscar(array(), 'Descricao');
     $this->view->produto = $produto;
     $this->view->etapa = $etapa;
     $this->view->item = $item;
     $this->view->itemPlanilhaAprovacao = $itemPlanilhaAprovacao;
     $this->view->comprovantes = $comprovantesDePagamento;
     $this->view->paises = $paises;
     if ($this->getRequest()->isPost()) {
         $this->view->vlComprovado = filter_input(INPUT_POST, 'vlComprovado');
         $this->view->idAgente = filter_input(INPUT_POST, 'idAgente');
         $this->view->CNPJCPF = filter_input(INPUT_POST, 'CNPJCPF');
         $this->view->Descricao = filter_input(INPUT_POST, 'Descricao');
         $this->view->tpDocumento = filter_input(INPUT_POST, 'tpDocumento');
         $this->view->nrComprovante = filter_input(INPUT_POST, 'nrComprovante');
         $this->view->nrSerie = filter_input(INPUT_POST, 'nrSerie');
         $this->view->dtEmissao = filter_input(INPUT_POST, 'dtEmissao');
         $this->view->tpFormaDePagamento = filter_input(INPUT_POST, 'tpFormaDePagamento');
         $this->view->nrDocumentoDePagamento = filter_input(INPUT_POST, 'nrDocumentoDePagamento');
         $this->view->dsJustificativa = filter_input(INPUT_POST, 'dsJustificativa');
     }
     $this->view->idpronac = $this->getRequest()->getParam('idpronac');
     $this->view->tipoDocumentoConteudo = $this->tipoDocumento;
 }