73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../../bbs/db_conn.php';
|
|
|
|
ini_set('display_errors', '0');
|
|
ini_set('display_startup_errors', '0');
|
|
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
|
|
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
try {
|
|
$pdo = db_conn();
|
|
|
|
// 파라미터 받기
|
|
$offer_date_fr = $_GET['offer_date_fr'] ?? '';
|
|
$offer_date_to = $_GET['offer_date_to'] ?? '';
|
|
$member_id = $_GET['member_id'] ?? '';
|
|
$reason = $_GET['reason'] ?? '';
|
|
$status_code = $_GET['status_code'] ?? '';
|
|
|
|
// 쿼리 빌드
|
|
$sql = "
|
|
SELECT
|
|
o.offer_id,
|
|
o.reference_url,
|
|
o.reason,
|
|
o.status_code,
|
|
COALESCE(c.code_name, o.status_code) AS status_name,
|
|
o.reason_return,
|
|
o.member_id,
|
|
u.name,
|
|
DATE(o.created_at) AS offer_date
|
|
FROM edu_content_offer o
|
|
LEFT JOIN edu_users u ON o.member_id = u.member_id AND o.sys_comp_code = u.sys_comp_code
|
|
LEFT JOIN edu_codes c ON c.group_code = 'OF100' AND c.base_code = o.status_code
|
|
WHERE 1=1
|
|
";
|
|
$params = [];
|
|
|
|
if ($offer_date_fr) {
|
|
$sql .= " AND DATE(o.created_at) >= ?";
|
|
$params[] = $offer_date_fr;
|
|
}
|
|
if ($offer_date_to) {
|
|
$sql .= " AND DATE(o.created_at) <= ?";
|
|
$params[] = $offer_date_to;
|
|
}
|
|
if ($member_id) {
|
|
$sql .= " AND (o.member_id LIKE ? OR u.name LIKE ?)";
|
|
$params[] = '%' . $member_id . '%';
|
|
$params[] = '%' . $member_id . '%';
|
|
}
|
|
if ($reason) {
|
|
$sql .= " AND o.reason LIKE ?";
|
|
$params[] = '%' . $reason . '%';
|
|
}
|
|
if ($status_code) {
|
|
$sql .= " AND o.status_code = ?";
|
|
$params[] = $status_code;
|
|
}
|
|
|
|
$sql .= " ORDER BY o.created_at DESC";
|
|
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute($params);
|
|
$offers = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
echo json_encode(['success' => true, 'offers' => $offers], JSON_UNESCAPED_UNICODE);
|
|
|
|
} catch (Exception $e) {
|
|
error_log('[GET_OFFERS ERROR] ' . $e->getMessage());
|
|
echo json_encode(['success' => false, 'message' => '서버 오류가 발생했습니다.'], JSON_UNESCAPED_UNICODE);
|
|
}
|
|
?>
|