|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home2/outerorb/.trash/survey_system/ | |
|
Path: /home2/outerorb/.trash/survey_system/export_excel.php
Size: 1.97 KB
Permissions: 0666
<?php
require_once 'config.php';
require_once 'inc/eventlog.php';
if(!is_logged_in() || !is_admin()){ header('Location: login.php'); exit; }
$stmt = $pdo->query('SELECT l.*, u.username AS agent_username, u.full_name AS agent_name, u.team AS team FROM leads l JOIN users u ON l.agent_id=u.id WHERE l.is_deleted=0 ORDER BY l.created_at DESC');
$rows = $stmt->fetchAll();
// Log the export action
$user = current_user();
log_event('data_export', ['export_type' => 'leads_excel', 'user_id' => $user['id'], 'record_count' => count($rows)]);
$fname = 'leads_export_' . date('Ymd_His') . '.xls';
header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
header('Content-Disposition: attachment; filename="' . $fname . '"');
echo "\xEF\xBB\xBF";
echo "<table border=1>";
echo "<tr><th>ID</th><th>Agent</th><th>Devices</th><th>Full Name</th><th>Phone</th><th>Email</th><th>Age</th><th>ISP</th><th>Rating</th><th>Internet</th><th>Main User</th><th>Status</th><th>Notes</th><th>Created At</th><th>Team</th></tr>";
foreach($rows as $r){
echo '<tr>';
echo '<td>' . htmlspecialchars($r['id']) . '</td>';
echo '<td>' . htmlspecialchars($r['agent_name']) . '</td>';
echo '<td>' . htmlspecialchars($r['devices']) . '</td>';
echo '<td>' . htmlspecialchars($r['full_name']) . '</td>';
echo '<td>' . htmlspecialchars($r['phone']) . '</td>';
echo '<td>' . htmlspecialchars($r['email']) . '</td>';
echo '<td>' . htmlspecialchars($r['age']) . '</td>';
echo '<td>' . htmlspecialchars($r['isp']) . '</td>';
echo '<td>' . htmlspecialchars($r['rating']) . '</td>';
echo '<td>' . htmlspecialchars($r['internet_type']) . '</td>';
echo '<td>' . htmlspecialchars($r['main_user']) . '</td>';
echo '<td>' . htmlspecialchars($r['status']) . '</td>';
echo '<td>' . htmlspecialchars(substr($r['notes'] ?? '',0,500)) . '</td>';
echo '<td>' . htmlspecialchars($r['created_at']) . '</td>';
echo '<td>' . htmlspecialchars($r['team']) . '</td>';
echo '</tr>';
}
echo '</table>';
exit;