File "read_single.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/valuation_rooms/read_single.php
File size: 1.18 KiB (1208 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
require_once '../../config/config.php';

$roomId = isset($_GET['room_id']) ? (int)$_GET['room_id'] : 0;

if ($roomId <= 0) {
    echo json_encode([
        'status' => 'error',
        'message' => 'Invalid room ID'
    ]);
    exit;
}

try {
    $sql = "SELECT 
        vr.room_id,
        vr.room_name,
        vr.incharge_id as supervisor_id,
        CONCAT(s.first_name, ' ', s.last_name) as supervisor_name,
        vr.capacity,
        1 as is_active,
        CURDATE() as created_at,
        CURDATE() as updated_at
    FROM valuation_rooms vr
    LEFT JOIN staff s ON vr.incharge_id = s.staff_id
    WHERE vr.room_id = ?";
    
    $stmt = $pdo->prepare($sql);
    $stmt->execute([$roomId]);
    $room = $stmt->fetch(PDO::FETCH_ASSOC);

    if ($room) {
        echo json_encode([
            'status' => 'success',
            'data' => $room
        ]);
    } else {
        echo json_encode([
            'status' => 'error',
            'message' => 'Room not found'
        ]);
    }

} catch (Exception $e) {
    error_log('Read Single Valuation Room Error: ' . $e->getMessage());
    
    echo json_encode([
        'status' => 'error',
        'message' => $e->getMessage()
    ]);
}
?>

PHP File Manager