public function imprimirProvidenciaTomadaAction() { $GrupoAtivo = new Zend_Session_Namespace('GrupoAtivo'); // cria a sessão com o grupo ativo $this->view->idPerfil = $GrupoAtivo->codGrupo; //DEFINE PARAMETROS DE ORDENACAO / QTDE. REG POR PAG. / PAGINACAO if ($this->_request->getParam("qtde")) { $this->intTamPag = $this->_request->getParam("qtde"); } $order = array(); //==== parametro de ordenacao ======// if ($this->_request->getParam("ordem")) { $ordem = $this->_request->getParam("ordem"); if ($ordem == "ASC") { $novaOrdem = "DESC"; } else { $novaOrdem = "ASC"; } } else { $ordem = "ASC"; $novaOrdem = "ASC"; } //==== campo de ordenacao ======// if ($this->_request->getParam("campo")) { $campo = $this->_request->getParam("campo"); $order = array($campo . " " . $ordem); $ordenacao = "&campo=" . $campo . "&ordem=" . $ordem; } else { $campo = null; $order = array(1); //Contador (id da tabela) $ordenacao = null; } $pag = 1; $get = Zend_Registry::get('post'); if (isset($get->pag)) { $pag = $get->pag; } $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0; $where = array(); $where['p.IdPRONAC = ?'] = $get->idPronac; $this->view->idPronac = $get->idPronac; $tblHisSituacao = new HistoricoSituacao(); $total = $tblHisSituacao->buscarHistoricosEncaminhamentoIdPronac($where, $order, null, null, true); $fim = $inicio + $this->intTamPag; $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1); $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag; $busca = $tblHisSituacao->buscarHistoricosEncaminhamentoIdPronac($where, $order, $tamanho, $inicio); $nrPronac = ''; $nrPronacNm = ''; if (count($busca) > 0) { $nrPronac = ' - Pronac: ' . $busca[0]->Pronac; $nrPronacNm = '_Pronac_' . $busca[0]->Pronac; } if (isset($get->xls) && $get->xls) { $html = ''; $html .= '<table style="border: 1px">'; if (!in_array($GrupoAtivo->codGrupo, array(90, 91, 94, 104, 105, 115, 118, 130, 1111))) { $html .= '<tr><td style="border: 1px dotted black; background-color: #EAF1DD; font-size: 16; font-weight: bold;" colspan="5">Consultar dados do Projeto - Providência Tomada' . $nrPronac . '</td></tr>'; $html .= '<tr><td style="border: 1px dotted black; background-color: #EAF1DD; font-size: 10" colspan="5">Data do Arquivo: ' . Data::mostraData() . '</td></tr>'; $html .= '<tr><td colspan="5"></td></tr>'; } else { $html .= '<tr><td style="border: 1px dotted black; background-color: #EAF1DD; font-size: 16; font-weight: bold;" colspan="3">Consultar dados do Projeto - Providência Tomada' . $nrPronac . '</td></tr>'; $html .= '<tr><td style="border: 1px dotted black; background-color: #EAF1DD; font-size: 10" colspan="3">Data do Arquivo: ' . Data::mostraData() . '</td></tr>'; $html .= '<tr><td colspan="3"></td></tr>'; } $html .= '<tr>'; $html .= '<th style="border: 1px dotted black; background-color: #9BBB59;">Dt. Situação</th>'; $html .= '<th style="border: 1px dotted black; background-color: #9BBB59;">Situação</th>'; $html .= '<th style="border: 1px dotted black; background-color: #9BBB59;">Providência Tomada</th>'; if (!in_array($GrupoAtivo->codGrupo, array(90, 91, 94, 104, 105, 115, 118, 130, 1111))) { $html .= '<th style="border: 1px dotted black; background-color: #9BBB59;">CPF</th>'; $html .= '<th style="border: 1px dotted black; background-color: #9BBB59;">Nome</th>'; } $html .= '</tr>'; foreach ($busca as $v) { $nrCpf = trim($v->cnpjcpf); if ($nrCpf == '00000000000') { $Cpf = '-'; $nomeUser = '******'; } else { $Cpf = strlen($nrCpf) > 11 ? Mascara::addMaskCNPJ($nrCpf) : Mascara::addMaskCPF($nrCpf); $nomeUser = $v->usuario; } $html .= '<tr>'; $html .= '<td style="border: 1px dotted black;">' . Data::tratarDataZend($v->DtSituacao, 'Brasileira') . '</td>'; $html .= '<td style="border: 1px dotted black;">' . $v->Situacao . '</td>'; $html .= '<td style="border: 1px dotted black;">' . $v->ProvidenciaTomada . '</td>'; if (!in_array($GrupoAtivo->codGrupo, array(90, 91, 94, 104, 105, 115, 118, 130, 1111))) { $html .= '<td style="border: 1px dotted black;">' . $Cpf . '</td>'; $html .= '<td style="border: 1px dotted black;">' . $nomeUser . '</td>'; } $html .= '</tr>'; } $html .= '</table>'; header("Content-Type: application/vnd.ms-excel"); header("Content-Disposition: inline; filename=Providencia_Tomada" . $nrPronacNm . ".xls;"); echo $html; die; } else { $this->view->nrPronac = $nrPronac; $this->view->qtdRegistros = $total; $this->view->dados = $busca; $this->view->intTamPag = $this->intTamPag; $this->_helper->layout->disableLayout(); // Desabilita o Zend Layout } }