Ir para conteúdo
Fórum Script Brasil

WillowFranco

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Tudo que WillowFranco postou

  1. Estou usando esse codigo para gerar um .xls, porém o mesmo está puxando todos os dados do banco e gerando um arquivo gigante. Alguma ajuda? <?php include ("../../includes/classes/conecta.class.php"); include ("../../includes/classes/auth.class.php"); include ("../../includes/classes/dateOpers.class.php"); include ("../../includes/queries/queries.php"); include ("../../includes/var_sessao.php"); include ("../../includes/config.inc.php"); include ("../../includes/versao.php"); include ("../../includes/languages/".LANGUAGE.""); include ("../../includes/include_geral_II.inc.php"); //algumas funcoes necessarias function converte_dma_para_amd($dataform) {//converte a data do formato dd/mm/aaaa para aaaa-mm-dd // if (strpos("-",$dataform)){ // $datatransf = explode("-",$dataform); // } else $datatransf = explode("/", $dataform); $data = "$datatransf[2]-$datatransf[1]-$datatransf[0]"; return $data; } function date_diff_dias($data1, $data2) { $s = strtotime($data2)-strtotime($data1); $d = intval($s/86400); $s -= $d*86400; $h = intval($s/3600); $s -= $h*3600; $m = intval($s/60); $s -= $m*60; $v = $d; return $v; } $numero = $_POST ['numero']; $area = $_POST ['area']; $problema = $_POST ['problema']; $instituicao = $_POST ['inst_nome']; $local = $_POST ['local']; $nome = $_POST ['nome']; $status_oco = $_POST ['nome_status']; $d_ini = $_POST ['data_abertura']; $d_fim = $_POST ['data_fechamento']; $html = ''; $html .= '<table align = "center" border="1" width="100%" cellpascing="1" cellpadding="0" >'; $html .= '<tr style="text-align:center">'; $html .= '<td bgcolor=#CCEEFF><b>Numero</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Problema</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Nome da Instituicao</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Local</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Nome</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Status</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Data Abertura</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Data Fechamento</b></td>'; $html .= '<td bgcolor=#CCEEFF><b>Dias em aberto</b></td>'; if ($saida==-1) //(modo normal) { print testa_user($s_usuario,$s_nivel,$s_nivel_desc,4); } $linhas=-1; $hora_inicio = ' 00:00:00'; $hora_fim = ' 23:59:59'; // letra.campo_tab as apelido $query = "select o.numero, o.problema as oco_problema, p.problema, o.sistema as oco_sistema, s.sistema, o.instituicao as oco_instituicao, i.inst_nome, o.local as oco_local, l.local, o.operador, u.login, u.nome, o.data_abertura, o.data_fechamento, o.status, st.stat_id,st.status as nome_status from ((ocorrencias as o left join sistemas as s on s.sis_id=o.sistema) left join instituicao as i on o.instituicao=i.inst_cod), problemas as p, localizacao as l, usuarios as u, `status` as st where o.problema=p.prob_id and o.local=l.loc_id and o.operador=u.user_id and o.status=st.stat_id"; if (!empty($problema) and ($problema != -1)) // variavel do select name { $query .= " and o.problema = $problema"; } if (!empty($area) and ($area != -1)) // variavel do select name { $query .= " and o.sistema = $area"; } if (!empty($instituicao) and ($instituicao != -1)) { $query .= " and o.instituicao = $instituicao"; } if (!empty($local) and ($local != -1)) { $query .= " and o.local = $local"; } if (!empty($operador) and ($operador != -1)) { $query .= " and o.operador = '$operador' "; } if (!empty($d_ini) and ($d_ini != -1)) { $query .= " and o.operador = '$d_ini' "; } if (!empty($d_fim) and ($d_fim != -1)) { $query .= " and o.operador = '$d_fim' "; } if (!empty($status_oco) and ($status_oco != -1)) { if ($status_oco == "Em aberto") { $query .= " and o.status not in (4,12) "; } else { $query .= " and o.status = $status_oco "; } } if (empty($d_ini)) { $d_ini = '01/03/2002'; } if (empty($d_fim)) { $hoje = getdate(); $mes = $hoje['mon']; $dia = $hoje['mday']; $ano = $hoje['year']; $d_fim = "$dia/$mes/$ano"; } //if (($d_ini < $d_fim) or ($d_ini == $d_fim)) //{ $d_ini = str_replace("-","/",$d_ini); $d_fim = str_replace("-","/",$d_fim); $d_ini_nova = converte_dma_para_amd($d_ini); $d_fim_nova = converte_dma_para_amd($d_fim); $d_ini_completa = $d_ini_nova.$hora_inicio; $d_fim_completa = $d_fim_nova.$hora_fim; switch ($tipo_data) { case -1: $query .= " and o.data_abertura>='$d_ini_completa' and o.data_abertura<='$d_fim_completa' and (o.data_fechamento>='$d_ini_completa' or o.data_fechamento is null) and (o.data_fechamento<='$d_fim_completa' or o.data_fechamento is null)"; break; case 1: $query .= " and o.data_abertura>='$d_ini_completa' and o.data_abertura<='$d_fim_completa'"; break; case 2: $query .= " and (o.data_fechamento>='$d_ini_completa' or o.data_fechamento is null) and (o.data_fechamento<='$d_fim_completa' or o.data_fechamento is null)"; break; } // switch $resultado = mysql_query($query); while ($row = mysql_fetch_array($resultado)) { $numero = $row ['numero']; $problema = $row ['problema']; $inst_nome = $row ['inst_nome']; $local = $row ['local']; $nome = $row ['nome']; $nome_status = $row ['Status']; $data_abertura = $row ['Data abertura']; $data_fechamento = $row ['Data fechamento']; $html .= '<tr style="text-align:center">'; $html .= '<td>' . $numero.'</td>'; $html .= '<td>' . $problema.'</td>'; $html .= '<td>' . $local. '</td>'; $html .= '<td>' . $instituicao. '</td>'; $html .= '<td>' . $nome . '</td>'; $html .= '<td>' . $status_oco . '</td>'; $html .= '<td>' . $data_abertura . '</td>'; $html .= '<td>' . $data_fechamento . '</td>'; $html .= '</tr>'; } $html .= '</table>'; $arquivo = 'Relatorio_Geral.xls'; header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); header ("Pragma: no-cache"); header ("Content-type: application/x-msexcel"); header ("Content-Disposition: attachment; filename=\"{$arquivo}\"" ); header ("Content-Description: PHP Generated Data" ); echo $html; exit; ?>
×
×
  • Criar Novo...