} else { array_push($put, $val["nome"]); } } if (isset($val["cod"])) { array_push($put, $val["cod"]); } else { array_push($put, '--'); } ksort($val["vs"]); foreach ($val["vs"] as $va) { //array_push($put,$va["v"]); if ($va["v"] != "") { array_push($put, str_replace(".", ",", $va["v"])); } else { array_push($put, '--'); } } array_push($A, $put); $put = array(); } } array_push($A, $put); return $A; } download_send_headers($nome . ".csv"); array2csv(ordenarV($result), $nome); //array2csv($result,$nome); //echo $json; echo $nome; die;
} } if ($data_csv != '') { $data_csv = json_decode($data_csv); // se nao receber path, gera php if ($output_path == '') { download_send_headers($filename); print array2csv($data_csv); } else { // se receber, gera arquivo e baixa // $output_web = "http://" . $_SERVER['HTTP_HOST'] . explode('baixar-csv.php', $_SERVER['PHP_SELF'])[0] . 'relatorios/arquivos/' . $filename; print array2csv($data_csv, $output_path . $filename); //print "<script>window.location='" . $output_web . "';</script>"; //print "<a href='" . $output_web . "'><h3 id='exportarCSVPost' class='csv' data_filename='relatorio_inscritos_setorial_estado'></h3></a>"; download_send_headers($filename, $output_path . $filename); } die; } else { ?> <!doctype html> <html lang="pt-BR"> <head> <title></title> <link rel="stylesheet" href="admin.css"> <script type="text/javascript" src="../../../wp-includes/js/jquery/jquery.js?ver=1.11.1"></script> <script type="text/javascript"> (function($) { $(document).ready(function(e) { // quando carregar, puxa dados do iframe parent var data_csv = $("#iframeExportar", parent.document.body).attr('data_csv'),
} function array2csv(array &$array, $titles) { if (count($array) == 0) { return null; } ob_start(); $df = fopen("php://output", 'w'); fputcsv($df, $titles, ';'); foreach ($array as $row) { fputcsv($df, $row, ';'); } fclose($df); return ob_get_clean(); } download_send_headers("data_export.csv"); echo array2csv($csv_data, $titles); die; } ?> <h3>Експорт</h3> <?php if ($data['unchecked_indexes'] == 0) { echo "У вас немає неперевірених даних"; } else { ?> <strong>Неперевірених показників: <?php echo $data['unchecked_indexes']; ?> </strong><br>
?> </td> <td><?php echo ${$class_third}->need_by_date; ?> </td> </tr> <?php $detailCount++; } ?> <?php $count = $count + 1; } ?> </tbody> </table> </div> </div> </div> <div id="print_footer"> </div> <?php $html = ob_get_contents(); ob_end_clean(); // send the captured HTML from the output buffer to the mPDF class for processing $mpdf->WriteHTML($html); download_send_headers("po_print" . date("Y-m-d") . ".pdf", 'pdf_format'); $mpdf->Output(); exit;
$total_sentimento = $conn->ArrayResult(); $total_sentimento["total"]; $sql = "UPDATE total_usuario_sentimento SET total= " . $total["total"]; //$conn->ExecuteSQL($sql); $listagem = $total["total"] - $total_sentimento["total"]; //echo "<br>"; $titulo = array("ID_REG_SEQ", "ID_USUARIO", "APELIDO", "IDADE", "SEXO", "EMAIL", "IDIOMA", "DT_CADASTRO", "DT_REGISTRO_DIA", "DT_REGISTRO_HORA", "LOC_REGISTRO", "REGIAO", "EQUIPAMENTO", "LAT", "LONG", "STATUS", "FEBRE", "TOSSE", "DORGARGANTA", "FALTAR", "NAUSEA", "DIARREIA", "ARTRALGIA", "CEFALEIA", "HEMORRAGIA", "EXANTEMA", "CONTATO", "SERVSAUDE", "CADASTRO", "SINTOMA", "CONTAGEM", "SIND_DIA", "SIND_RES", "SIND_EXA", "ATUALIZA"); /* $sql = "SELECT u.id, u.apelido, u.idade, u.sexo, u.email , u.data_hora, u.hash, u.gcmid, u.idioma, us.data_cadastro, us.pontuacao, us.latitude, us.longitude, c.nome, us.campo1, us.campo2, us.campo3, us.campo4, us.campo5, us.campo6, us.campo7, us.campo8, us.campo9, us.campo10, us.campo11, us.campo12 FROM usuarios u INNER JOIN usuario_sentimento us ON us.usuario_id = u.id INNER JOIN cidade c ON us.cidade_id = c.id"; */ $sql = "SELECT \nus.id,\nus.usuario_id as usuario_id, u.apelido, \nu.idade, u.sexo, \nu.email ,u.idioma, \nus.data_cadastro as data_cadastro,\nDate(us.data_cadastro) as data_cadastro_dia,\nTime(us.data_cadastro) as data_cadastro_hora,\nus.cidade_id as cidade,\nus.cidade_regiao_metro as regiao,\nu.device,\nus.latitude as latitude, us.longitude as longitude, us.sentimento as sentimento,\nus.campo1 as campo1, us.campo2 as campo2, us.campo3 as campo3,\nus.campo4 as campo4, us.campo5 as campo5, us.campo6 as campo6, \nus.campo7 as campo7, us.campo8 as campo8, us.campo9 as campo9,\nus.campo10 as campo10, us.campo11 as campo11, us.campo12 as campo12, \nu.data_hora as data_hora\nFROM usuarios u\nINNER JOIN usuario_sentimento us ON us.usuario_id = u.id\norder by us.usuario_id, us.data_cadastro\nlimit 0,30"; //limit " . $total_sentimento["total"] . "," . $listagem; $conn->ExecuteSQL($sql); $array[0] = $titulo; $array[1] = $conn->ArrayResults(); $recife = new DateTimeZone("America/Recife"); $HoraBrasilia = new DateTime(); $HoraBrasilia->setTimezone($recife); $Hora = $HoraBrasilia->format("H_i_s"); $arquivo = "saudenacopa.csv"; echo array2csv($array, $conn, $arquivo); download_send_headers($arquivo); //download_send_headers("saudenacopa_" . date("Y_m_d") . "_" . $Hora . ".csv"); die;
} } fputcsv($df, $row); } fclose($df); return ob_get_clean(); } function download_send_headers($filename) { // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } if (isset($_POST['csv_download']) && $options['settings']['is_key_valid']) { download_send_headers("data_export_" . date("Y-m-d") . ".csv"); echo array2csv($options['feeds']); die; } /* echo "<pre>"; print_r($options); exit; */
<?php require_once "wp-config.php"; global $wpdb; $sql = "SELECT * FROM tb_postulaciones_itpeople WHERE eliminado = 0 AND id_oferta = " . $_REQUEST['id']; $postulaciones = $wpdb->get_results($sql); $rows = array(); foreach ($postulaciones as $p) { $row = array("Nombre" => $p->nombre, "E-mail" => $p->email, "Teléfono" => $p->telefono, "Tecnologías" => $p->tecnologias, "Años experiencia" => $p->anios_experiencia, "Disponibilidad" => $p->disponibilidad, "Renta líquida" => $p->renta_liquida, "Observaciones" => $p->observaciones, "Aprobado" => $p->aprobado == 1 ? "SI" : "NO"); $rows[] = $row; } download_send_headers("postulantes_" . $_REQUEST['id'] . ".csv"); echo utf8_decode(array2csv($rows)); function download_send_headers($filename) { // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } function array2csv(array &$array) { if (count($array) == 0) {
<?php require 'functions.php'; include 'connect.php'; $sql = "select a.codepin, a.email_proprio, a.nom_proprio, a.prenom_proprio, a.tel_proprio, a.code_postal, a.datCreat\r\r\n from em_animal a, em_pin_free f where f.loterie = 1 and f.codepin = a.codepin\r\r\n order by a.datCreat "; $res = $DB->query($sql); if ($res) { $arr = $res->fetchAll(PDO::FETCH_ASSOC); download_send_headers("qrv_loterie_" . date("Y-m-d") . ".csv"); echo array2csv($arr); die; }
// disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } function array2csv(array &$array) { if (count($array) == 0) { return null; } ob_start(); $df = fopen("php://output", 'w'); foreach ($array as $row) { fputcsv($df, $row); } fclose($df); return ob_get_clean(); } // echo "<pre>"; //print_r($metaArray); download_send_headers("meta_data_export_" . date("Y-m-d-H-i-s") . ".csv"); echo array2csv($metaArray); die;
function download_send_headers($fn) { $now = gmdate("D, d M y H:i:s"); // disable caching header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename=\"" . $fn . "\""); header("Content-Transfer-Encoding: binary"); } download_send_headers("{$original_name}.zip"); readfile($filename); unlink($filename); die; } ?> <html> <head> <link rel="stylesheet" type="text/css" href="css/reset.css"> <link rel="stylesheet" type="text/css" href="css/font-awesome.css"> <link rel="stylesheet" type="text/css" href="css/main.css"> <meta charset="UTF-8"> <meta name="robots" content="noindex">
header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } include "class.MySQL.php"; $conn = new MySQL(); $arquivo = 'planilha_download_saude_na_copa.xls'; $titulo = array("ID_REG_SEQ", "ID_USUARIO", "APELIDO", "IDADE", "SEXO", "EMAIL", "IDIOMA", "DT_CADASTRO", "DT_REGISTRO_DIA", "DT_REGISTRO_HORA", "LOC_REGISTRO", "REGIAO", "EQUIPAMENTO", "LAT", "LONG", "STATUS", "FEBRE", "TOSSE", "DORGARGANTA", "FALTAR", "NAUSEA", "DIARREIA", "ARTRALGIA", "CEFALEIA", "HEMORRAGIA", "EXANTEMA", "CONTATO", "SERVSAUDE", "CADASTRO", "SINTOMA", "CONTAGEM"); /* $sql = "SELECT u.id, u.apelido, u.idade, u.sexo, u.email , u.data_hora, u.hash, u.gcmid, u.idioma, us.data_cadastro, us.pontuacao, us.latitude, us.longitude, c.nome, us.campo1, us.campo2, us.campo3, us.campo4, us.campo5, us.campo6, us.campo7, us.campo8, us.campo9, us.campo10, us.campo11, us.campo12 FROM usuarios u INNER JOIN usuario_sentimento us ON us.usuario_id = u.id INNER JOIN cidade c ON us.cidade_id = c.id"; */ $sql = "SELECT \nus.id,\nus.usuario_id as usuario_id, u.apelido, \nu.idade, u.sexo, \nu.email ,u.idioma, \nus.data_cadastro as data_cadastro,\nDate(us.data_cadastro) as data_cadastro_dia,\nTime(us.data_cadastro) as data_cadastro_hora,\nus.cidade_id as cidade,\nus.cidade_regiao_metro as regiao,\nu.device,\nus.latitude, us.longitude, us.sentimento as sentimento,\nus.campo1 as campo1, us.campo2 as campo2, us.campo3 as campo3,\nus.campo4 as campo4, us.campo5 as campo5, us.campo6 as campo6, \nus.campo7 as campo7, us.campo8 as campo8, us.campo9 as campo9,\nus.campo10 as campo10, us.campo11 as campo11, us.campo12 as campo12, \nu.data_hora as data_hora\nFROM usuarios u\nINNER JOIN usuario_sentimento us ON us.usuario_id = u.id\norder by us.usuario_id, us.data_cadastro"; $conn->ExecuteSQL($sql); $array[0] = $titulo; $array[1] = $conn->ArrayResults(); //download_send_headers("SaudeNaCopa_" . date("Y-m-d-H-i-s") . ".csv"); download_send_headers("SaudeNaCopa_" . date("Y_m_d_H_i_s") . ".csv"); echo array2csv($array); die;
public function __construct($ordem_id = null, $ordem = null, $pag = null, $espc = null, $start = null, $estado = null, $estados_pos = null, $load_more = false, $download = false, $ano = 3, $lang = null) { $limit = 100; if ($lang != null) { //Se $lang for diferente de null $this->lang = $lang; } else { if (get_class($ordem_id) == "LangManager") { //Se a classe de $ordem_id for igual a LangManager $this->lang = $ordem_id; $ordem_id = null; } } $this->showBtn = $load_more; if ($load_more) { $limit = 12000; } if (is_null($ordem_id)) { //Se $ordem_id for null $ordem_id = INDICADOR_IDH; //INDICADOR_IDH é igual a 196 } if (is_null($ordem)) { //Se $ordem for igual a null $ordem = "asc"; //$ordem será igual a asc } if (is_null($limit)) { //Se $lmiti for igual a null $limit = 100; } if (is_null($espc)) { //Se $espc for igual a null $espc = "municipal"; } if (is_null($pag)) { //Se $pag for igual a null $pag = 1; } if (is_null($start) || $start < 0) { $start = 1; } if (is_null($estado)) { $estado = 0; } if ($ordem != "desc" && $ordem != "asc") { $ordem = "asc"; } $this->fkAno = (int) $ano; if ($this->fkAno == 0) { $this->fkAno = 3; } if (($espc == 'udh' || $espc == 'rm') && $this->fkAno == 1) { //Para rm e udh o ano será somente 2010 $this->fkAno = 3; } $this->pOrdem_id = (int) $ordem_id; $this->pOrdem = $ordem; $this->pLimit = (int) $limit; $this->pEspc = $espc; $this->pPag = (int) $pag; $this->pStart = (int) $start; $this->pEstado = (int) $estado; $bd = new bd(); $rankingBy = ""; //Colunas do Ranking. Os Cases indicam a primeira coluna switch ($ordem_id) { case INDICADOR_IDH: //Coluna IDHM $this->nOrdem = $this->lang->getString("rankin_idhm"); //Nome da Coluna $rankingBy = "posicao_idh"; break; case INDICADOR_RENDA: //Coluna IDHM RENDA $this->nOrdem = $this->lang->getString("rankin_renda2"); $rankingBy = "posicao_idhr"; break; case INDICADOR_LONGEVIDADE: //Coluna IDHM LONGEVIDADE $this->nOrdem = $this->lang->getString("rankin_Long"); $rankingBy = "posicao_idhl"; break; case INDICADOR_EDUCACAO: //Coluna IDHM EDUCAÇÃO $this->nOrdem = $this->lang->getString("rankin_edu"); $rankingBy = "posicao_idhe"; break; default: break; } // echo $this->fkAno; //Dentro de $this->sql_proto[$espc], onde tiver VARS, substitui pelo valor de $ordem_id $sql_seletor = str_replace("VARS", $ordem_id, $this->sql_proto[$espc]) . " ORDER BY ot {$ordem} LIMIT {$limit} offset " . ($pag - 1) * $limit; //Dentro de $sql_seletor, onde tiver (ANO), substitui pelo valor de $this->fkAno $sql_seletor = str_replace("(ANO)", $this->fkAno, $sql_seletor); if ($this->pEstado > 0 && $espc == "municipal") { $sql_seletor = str_replace("(MOREWHERE)", " AND e.id = {$this->pEstado} ", $sql_seletor); $rankingBy = str_replace("_", "_e_", $rankingBy); } else { if ($this->pEstado > 0 && $espc == "udh") { $sql_seletor = str_replace("(MOREWHERE)", " AND e.id = {$this->pEstado} ", $sql_seletor); $rankingBy = str_replace("_", "_r_", $rankingBy); } else { //Dentro de $sql_seletor, onde tiver (MOREWHERE), substituir por ""(vazio) $sql_seletor = str_replace("(MOREWHERE)", "", $sql_seletor); } } $sql_seletor = str_replace("(TBS)", ",{$rankingBy} as ot", $sql_seletor); $res = $bd->ExecutarSQL($sql_seletor, "frist"); $ids = array(); if ($espc == "municipal") { //Se a espacialidade for igual a 'municipal' foreach ($res as $key => $val) { $this->municipio = array("mun" => "{$val["n"]}", "uf" => "{$val["uf"]}"); $this->data[$val["i"]] = array("mun" => "{$val["n"]}", "uf" => "{$val["uf"]}", "n" => "{$val["n"]} ({$val["uf"]})", "ot" => $val["ot"], "vs" => array($ordem_id => array("v" => $val["v"], "k" => $ordem_id))); $ids[] = $val["i"]; //Salva no array $ids as chaves de município } $SQL_e = "SELECT nome, id FROM estado order by nome"; //Retorna os nomes dos estados $resp = $bd->ExecutarSQL($SQL_e, "estado 22"); $this->estados = $resp; } else { if ($espc == "udh") { //Se a espacialidade for igual a 'udh' foreach ($res as $key => $val) { $this->data[$val["i"]] = array("udh" => "{$val["n"]}", "mun" => "{$val["nrm"]}", "idgeo" => "{$val['idgeo']}", "n" => "{$val["n"]} ({$val["nrm"]})", "ot" => $val["ot"], "vs" => array($ordem_id => array("v" => $val["v"], "k" => $ordem_id))); $ids[] = $val["i"]; //Salva no array $ids as chaves de município } $SQL_e = "SELECT nome, id FROM rm WHERE ativo = TRUE order by nome"; //Retorna os nomes dos estados $resp = $bd->ExecutarSQL($SQL_e, "ranking 16"); $this->estados = $resp; } else { if ($espc == "estadual" || $espc == 'rm') { //Se a espacialidade for estadual $counter = 0; $last = 0; $hidden_array = array(); $arr = explode(",", $estados_pos); $t = count($arr) - 1; foreach ($res as $key => $val) { if ($ordem == "desc") { if ($last != cutNumber($val["v"], 3, '.')) { $counter++; } $last = cutNumber($val["v"], 3, '.'); } if ($ordem == "asc") { $counter = $arr[$t]; if ($t != 0) { $t--; } } $hidden_array[] = $counter; $val_at = isset($val['at']) ? $val['at'] : ''; $this->data[$val["i"]] = array("ot" => $val["ot"], "n" => "{$val["n"]}", "ativo" => "{$val_at}", "vs" => array($ordem_id => array("v" => $val["v"], "k" => $ordem_id))); $ids[] = $val["i"]; } echo "<input type='hidden' value='" . join(",", $hidden_array) . "' id='holderRankEstados' />"; } } } $places = implode(",", $ids); //Separa cada id de município por uma vírgula $vars = implode(",", array_diff($this->id_indics, array($ordem_id))); //Retorna a diferença entre os arrays $var_name = ""; if ($espc == "municipal") { $var_name = "fk_municipio"; } elseif ($espc == "estadual") { $var_name = "fk_estado"; } else { if ($espc == 'rm') { $var_name = 'fk_rm'; } else { if ($espc == 'udh') { $var_name = 'fk_udh'; } } } //Dentro de $this->sql_f[$espc], onde tiver (ANO), substitui pelo valor de $this->fkAno $this->sql_f[$espc] = str_replace("(ANO)", $this->fkAno, $this->sql_f[$espc]); //Dentro de $this->sql_f[$espc]) . " and $var_name IN ($places) order by fk_variavel, onde tiver VARS, substitui pelo valor de $vars //Valores das outras 3 colunas do ranking $sql_follower = str_replace("VARS", $vars, $this->sql_f[$espc]) . " and {$var_name} IN ({$places}) order by fk_variavel"; $res_f = $bd->ExecutarSQL($sql_follower); foreach ($res_f as $key => $val) { $this->data[$val["i"]]["vs"][$val["k"]] = array("v" => $val["v"], "k" => $val["k"]); } if ($download) { ob_end_clean(); //Encerro o segundo buffer de saída da pilha e jogo conteúdo fora ob_clean(); // Limpo o primeiro buffer de saída /*echo "\t";*/ $n = $this->getNomeIndicador($ordem_id); $n = str_replace(" ", "_", $n); if ($espc == "municipal") { if ($estado == 0) { download_send_headers("AtlasIDHM_RankingMunicipal_" . $n . "_" . convertAnoIDtoLabel($this->fkAno) . "_Brasil.csv"); } else { $n2 = $this->getEstadoNome(); $n2 = str_replace(" ", "_", $n2); download_send_headers("AtlasIDHM_RankingMunicipal_" . $n . "_" . convertAnoIDtoLabel($this->fkAno) . "_{$n2}.csv"); } } else { if ($espc == "estadual") { download_send_headers("AtlasIDHM_RankingEstadual_" . convertAnoIDtoLabel($this->fkAno) . ".csv"); } else { if ($espc == 'rm') { download_send_headers("AtlasIDHM_RankingRM_" . convertAnoIDtoLabel($this->fkAno) . ".csv"); } else { if ($espc == 'udh') { download_send_headers("AtlasIDHM_RankingUDH_" . convertAnoIDtoLabel($this->fkAno) . ".csv"); } } } } foreach ($this->data as $key => $val) { $c = 0; echo "sep=;\n"; echo utf8_decode($lang->getString("cols_ranking_pos") . ";" . $lang->getString("cols_ranking_na") . ";"); foreach ($val["vs"] as $k => $v) { $or = "desc"; $class = ""; $class_ds = ""; switch ($v["k"]) { case INDICADOR_IDH: echo "{$this->lang->getString("rankin_idhm")} (" . convertAnoIDtoLabel($this->fkAno) . ")"; break; case INDICADOR_RENDA: echo "{$this->lang->getString("rankin_renda")} (" . convertAnoIDtoLabel($this->fkAno) . ")"; break; case INDICADOR_LONGEVIDADE: echo "{$this->lang->getString("rankin_Long")} (" . convertAnoIDtoLabel($this->fkAno) . ")"; break; case INDICADOR_EDUCACAO: echo utf8_decode("{$this->lang->getString("rankin_edu")}") . " (" . convertAnoIDtoLabel($this->fkAno) . ")"; break; default: break; } if ($c <= 2) { echo ";"; } $c++; } break; } echo "\n"; $ts = false; $counter = 0; $last = "0"; $answer = ""; $j = 0; foreach ($this->data as $key => $val) { $n = (double) cutNumber($val["vs"][INDICADOR_IDH]['v'], 3, '.'); if (cutNumber($val["vs"][$this->pOrdem_id]['v'], 3, '.', '') != $last) { $counter++; } $answer .= "{$val["ot"]} º;"; $answer .= "{$val["n"]};"; /*$answer.= str_replace(",", "-", $val["n"]). ",";*/ $c = 0; foreach ($val["vs"] as $k => $v) { $val["vs"][$k]["v"] = cutNumber($v["v"], 3, ',', ''); if ($c <= 2) { $answer .= $val["vs"][$k]["v"] . ";"; } else { $answer .= $val["vs"][$k]["v"]; } $c++; } $last = $val["vs"][$this->pOrdem_id]['v']; $answer .= "\n"; $ts = !$ts; $j++; } echo utf8_decode($answer); if (isset($_POST["cross_data_download"])) { $_POST["cross_data_download"] = false; } die; } }
<?php session_start(); $_POST = json_decode(file_get_contents("php://input"), true); if (isset($_SESSION['course_id'])) { function download_send_headers($filename) { // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } download_send_headers($_SESSION['export_name'] . "_" . date("Y-m-d") . ".csv"); echo $_SESSION['export_data']; $_SESSION['export_data'] = ''; $_SESSION['export_name'] = ''; die; }
}); $app->get('/export-db-owner', function () use($app) { $staff_array = $app['session']->get('staff'); if ($staff_array == null) { return $app['twig']->render('illegal.twig', array('group' => false)); } else { if ($staff_array['staff'] == false) { return $app['twig']->render('illegal.twig', array('group' => false)); } else { $st = $app['pdo']->prepare('SELECT first_name, last_name, address FROM users WHERE user_type_fk = 2 ORDER BY address'); $st->execute(); $niews = array(); while ($row = $st->fetch(PDO::FETCH_ASSOC)) { $niews[] = $row; } download_send_headers("info_proprietaires_" . date("Y-m-d") . ".csv"); echo array2csv($niews); die; $su = false; $tmp = $app['session']->get('superuser'); if ($tmp == null) { $su = false; } else { $su = $tmp['superuser']; } return $app['twig']->render('test-db.twig', array('superuser' => $su)); } } }); $app->match('/courthistory', function (Request $request) use($app) { $staff_array = $app['session']->get('staff');
case 'xml_format': $format_extn = '.txt'; break; case 'worddoc_format': $format_extn = '.doc'; break; case 'pdf_format': $format_extn = '.pdf'; break; case 'text_format': default: $format_extn = '.txt'; break; } //pa($array_var); download_send_headers("data_export_" . date("Y-m-d") . "{$format_extn}", $download_format); //download_send_headers("data_export_" . date("Y-m-d") . ".html"); switch ($download_format) { case 'excel_format': if (is_array($array_var)) { echo array2csv($array_var); } break; case 'xml_format': if (is_array($array_var)) { echo array2xml($array_var); } break; case 'worddoc_format': if (is_array($array_var)) { echo array2worddoc($array_var);
function exportData() { function build_sorter($key) { return function ($a, $b) use($key) { return strnatcmp($a->{$key}, $b->{$key}); }; } $permits = $this->session->userdata(); $prod = array_merge($permits['foda']['view'], $permits['metaP']['view']); $finan = array_merge($permits['valorF']['view'], $permits['metaF']['view']); if (count($prod) + count($finan) <= 0) { redirect('inicio'); } $this->form_validation->set_rules('graphic', 'Gráfico', 'required|numeric|greater_than_equal_to[0]'); $this->form_validation->set_rules('all', 'Todo', 'required|numeric|in_list[0,1]'); if (!$this->form_validation->run()) { redirect('inicio'); } $graphic = $this->input->post('graphic'); $all = strcmp($this->input->post('all'), "1") == 0 ? true : false; $graphic = $all ? $this->Dashboard_model->getAllGraphicData($graphic) : $this->Dashboard_model->getGraphicData($graphic); $key = $all ? 'year' : 'x'; $data = []; $metric = (object) ["x_name" => "Año"]; foreach ($graphic->series as $serie) { $prename = $all || strcmp($serie->aggregation, "") == 0 ? "" : $serie->aggregation . " de "; $metorg = $this->Metorg_model->getMetOrg(['id' => [$serie->metorg]])[0]; $metric = $this->Metrics_model->getMetric(['id' => [$metorg->metric]])[0]; foreach ($serie->values as $value) { if (!key_exists('target', $value)) { continue; } $value->metric = $prename . $serie->name . " de " . $serie->org; $data[] = $value; } } $graphic->x_name = $all ? $metric->x_name : $graphic->x_name; $title = $graphic->title . " Periodo (" . $graphic->min_year . " - " . $graphic->max_year . ")"; usort($data, build_sorter($key)); download_send_headers(str_replace(" ", "_", $title) . "_" . date("d-m-Y") . ".csv"); echo array2csv($data, $title, $graphic->x_name, $graphic->y_name, $all); return; }
{ // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } include "class.MySQL.php"; $conn = new MySQL(); $arquivo = 'planilha_download_saude_na_copa.xls'; $titulo = array("ID_REG_SEQ", "ID_USUARIO", "APELIDO", "IDADE", "SEXO", "EMAIL", "IDIOMA", "DT_CADASTRO", "DT_REGISTRO_DIA", "DT_REGISTRO_HORA", "LOC_REGISTRO", "REGIAO", "EQUIPAMENTO", "LAT", "LONG", "STATUS", "FEBRE", "TOSSE", "DORGARGANTA", "FALTAR", "NAUSEA", "DIARREIA", "ARTRALGIA", "CEFALEIA", "HEMORRAGIA", "EXANTEMA", "CONTATO", "SERVSAUDE", "CADASTRO", "SINTOMA", "SIND_DIA", "SIND_RES", "SIND_EXA", "TOTAL"); //, "ATUALIZA"); $sql = "SELECT ID_REG_SEQ, ID_USUARIO ,APELIDO,IDADE, SEXO, EMAIL, IDIOMA , DT_CADASTRO,\nDT_REGISTRO_DIA, DT_REGISTRO_HORA, LOC_REGISTRO , REGIAO , EQUIPAMENTO,\nLATITUDE ,LONGITUDE, STATUS, FEBRE, TOSSE, DORGARGANTA, FALTAR, NAUSEA,\nDIARREIA, ARTRALGIA, CEFALEIA, HEMORRAGIA, EXANTEMA, CONTATO, SERVSAUDE,\nCADASTRO, SINTOMA, SIND_DIA, SIND_RES, SIND_EXA, total FROM `csv_leve` inner join lastinsert on ultimo = csv_leve.ID_REG_SEQ"; $conn->ExecuteSQL($sql); $array[0] = $titulo; $array[1] = $conn->ArrayResults(); $recife = new DateTimeZone("America/Recife"); $HoraBrasilia = new DateTime(); $HoraBrasilia->setTimezone($recife); $Hora = $HoraBrasilia->format("H_i_s"); //download_send_headers("SaudeNaCopa_" . date("Y-m-d-H-i-s") . ".csv"); download_send_headers("saudenacopa_" . date("Y_m_d") . "_" . $Hora . ".csv"); echo array2csv($array, $conn); die;
{ // disable caching $now = gmdate("D, d M Y H:i:s"); header("Expires: Tue, 03 Jul 2001 06:00:00 GMT"); header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate"); header("Last-Modified: {$now} GMT"); // force download header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); // disposition / encoding on response body header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } function array2csv(array &$array) { if (count($array) == 0) { return null; } ob_start(); $df = fopen("php://output", 'w'); fputcsv($df, array_keys(reset($array))); foreach ($array as $row) { fputcsv($df, $row); } fclose($df); return ob_get_clean(); } download_send_headers("feedback_export_" . date("Y-m-d") . ".csv"); echo array2csv($allFeedbacks); die;
header("Content-Disposition: attachment;filename={$filename}"); header("Content-Transfer-Encoding: binary"); } // **************************************************************** // access check include "includes/startloggedinadmin.inc.php"; require_once "classes/constants.class.php"; //require_once "classes/template.class.php"; //require_once "classes/templatehelper.class.php"; require_once "classes/db.class.php"; require_once "classes/sessionhelper.class.php"; //require_once "classes/jswriter.class.php"; //require_once "classes/validationhelper.class.php"; require_once "classes/bookingshelper.class.php"; if (!SessionHelper::isMaster()) { die("You don't belong here!"); } $db = new Db(); $q = "\nSELECT \n\tb.first_name AS first_name,\n\tb.last_name AS last_name,\n\tb.email AS email\nFROM\n\tbookings b\nGROUP BY \n\temail\nORDER BY \n\temail\n"; //pr($q); // exit(); $rows = $db->getRowsByQuery($q); $rows2 = array(); foreach ($rows as $row) { $rows2[] = array("name" => $row["first_name"], "surname" => $row["last_name"], "email" => $row["email"]); } unset($rows); //pr($rows2); exit; // ********************* export it now *****************9 download_send_headers("aps_emails_export_" . date("Y-m-d") . ".csv"); echo array2csv($rows2); die;
</td> <td><?php echo ${$class_second}->so_order_number; ?> </td> <td><?php echo ${$class_second}->so_line_number; ?> </td> </tr> <?php $count = $count + 1; } ?> </tbody> </table> </div> </div> </div> <div id="print_footer"> </div> <?php $html = ob_get_contents(); ob_end_clean(); //echo $html; // send the captured HTML from the output buffer to the mPDF class for processing $mpdf->WriteHTML($html); download_send_headers("ar_transaction_print" . date("Y-m-d") . ".pdf"); $mpdf->Output(); exit;