Created
March 30, 2016 18:03
-
-
Save valdiney/9112391cd08f5dfb394d7b2186096470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exporta os dados para um arquivo txt | |
public function exportar_clientes_para_txt() | |
{ | |
$data_files = 'public/data_files/clientes_files.txt'; | |
# Abre o arquivo | |
$file = fopen($data_files, 'w'); | |
# Pega os dados da tabela | |
$data_from_db = $this->radacct->select()->get_all(); | |
foreach ($data_from_db as $key => $cliente) { | |
# Busca o nome do visitante na tabela (Visitantes) | |
$data_visitante = $this->visitante->find_by('email', $cliente->username); | |
# Prepara os campos que serão alocado no arquivo txt | |
$prepara_os_dados = $data_visitante['nome'] . ', '; | |
$prepara_os_dados .= $cliente->username . ', '; | |
$prepara_os_dados .= $cliente->acctstarttime . ', '; | |
$prepara_os_dados .= $cliente->nasipaddress . ', '; | |
$prepara_os_dados .= $cliente->callingstationid . ', '; | |
$prepara_os_dados .= $cliente->calledstationid . ', ' . "\r\n"; | |
# Passa os campos para o arquivo | |
fwrite($file, $prepara_os_dados); | |
} | |
fclose($file); | |
Session::flash('success', 'Arquivo gerado com Sucesso! <a href="public/data_files/clientes_files.txt" download>Fazer o Download do arquivo</a>'); | |
return Redirect::back(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment