feat(cdr): add Call Logs & CDR module with automatic trunk detection and CSV export (v1.6.0)
This commit is contained in:
1 parent
a9d86dd6ac
commit
7c28a237ba
5 files changed
+927
-1
No files matched your search
@@ -11,6 +11,7 @@ require_once __DIR__ . '/../src/CertificateManager.php';
|
||||
require_once __DIR__ . '/../src/BackupManager.php';
|
||||
require_once __DIR__ . '/../src/FirewallManager.php';
|
||||
require_once __DIR__ . '/../src/PhonebookManager.php';
|
||||
require_once __DIR__ . '/../src/CdrManager.php';
|
||||
|
||||
use App\Database;
|
||||
use App\Auth;
|
||||
@@ -22,6 +23,7 @@ use App\CertificateManager;
|
||||
use App\BackupManager;
|
||||
use App\FirewallManager;
|
||||
use App\PhonebookManager;
|
||||
use App\CdrManager;
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
@@ -2276,6 +2278,49 @@ try {
|
||||
echo json_encode($res);
|
||||
break;
|
||||
|
||||
case 'get_cdr':
|
||||
Auth::requireAuth();
|
||||
$filters = [
|
||||
'limit' => (int)($_GET['limit'] ?? $payload['limit'] ?? 100),
|
||||
'direction' => (string)($_GET['direction'] ?? $payload['direction'] ?? 'all'),
|
||||
'disposition' => (string)($_GET['disposition'] ?? $payload['disposition'] ?? 'all'),
|
||||
'period' => (string)($_GET['period'] ?? $payload['period'] ?? 'all'),
|
||||
'search' => (string)($_GET['search'] ?? $payload['search'] ?? ''),
|
||||
];
|
||||
$cdrData = CdrManager::getCalls($db, $filters);
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'calls' => $cdrData['calls'],
|
||||
'stats' => $cdrData['stats'],
|
||||
'total_records' => $cdrData['total_records'],
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'export_cdr_csv':
|
||||
Auth::requireAuth();
|
||||
$filters = [
|
||||
'direction' => (string)($_GET['direction'] ?? 'all'),
|
||||
'disposition' => (string)($_GET['disposition'] ?? 'all'),
|
||||
'period' => (string)($_GET['period'] ?? 'all'),
|
||||
'search' => (string)($_GET['search'] ?? ''),
|
||||
];
|
||||
$csv = CdrManager::exportCsv($db, $filters);
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment; filename="nexuspbx_journal_appels_' . date('Y-m-d_His') . '.csv"');
|
||||
header('Pragma: no-cache');
|
||||
header('Expires: 0');
|
||||
echo $csv;
|
||||
exit;
|
||||
|
||||
case 'clear_cdr':
|
||||
Auth::requireAuth();
|
||||
$cleared = CdrManager::clearCdr();
|
||||
echo json_encode([
|
||||
'success' => $cleared,
|
||||
'message' => $cleared ? "Journal d'appels réinitialisé avec succès." : "Impossible de vider le fichier CDR.",
|
||||
]);
|
||||
break;
|
||||
|
||||
case 'check_update':
|
||||
$appDir = dirname(__DIR__);
|
||||
clearstatcache(true, "{$appDir}/version.json");
|
||||
|
||||
Reference in new issue
Block a user