37 lines
961 B
PHP
37 lines
961 B
PHP
<?php
|
|
require_once(__DIR__ . '/class/db-functions.php');
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
try {
|
|
$idclient = intval($_GET['idclient'] ?? 0);
|
|
|
|
$query = "
|
|
SELECT
|
|
cf.id,
|
|
c.client_name,
|
|
cf.file_type,
|
|
cf.filename,
|
|
cf.source_id,
|
|
cf.upload_date,
|
|
cf.notes
|
|
FROM client_files cf
|
|
LEFT JOIN clients c ON c.idclient = cf.idclient
|
|
" . ($idclient > 0 ? "WHERE cf.idclient = :idclient" : "") . "
|
|
ORDER BY cf.upload_date DESC
|
|
";
|
|
|
|
$stmt = $pdo->prepare($query);
|
|
if ($idclient > 0) {
|
|
$stmt->bindValue(':idclient', $idclient, PDO::PARAM_INT);
|
|
}
|
|
$stmt->execute();
|
|
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
echo json_encode($data);
|
|
} catch (Exception $e) {
|
|
echo json_encode(['status' => 'error', 'message' => $e->getMessage()]);
|
|
}
|