<?php
require_once 'config.php';

if (!isset($_SESSION['user_id'])) response(["error" => "No autorizado"], 401);

$stmt = $pdo->query("SELECT * FROM properties ORDER BY code ASC");
response($stmt->fetchAll());
?>
```

# api/save_property.php
```php
<?php
require_once 'config.php';

if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_role'], ['admin', 'programmer'])) {
    response(["error" => "No autorizado"], 401);
}

$data = json_decode(file_get_contents("php://input"), true);

if (isset($data['id'])) {
    // UPDATE
    $stmt = $pdo->prepare("UPDATE properties SET 
        code = ?, type = ?, tower = ?, floor = ?, number = ?, aliquot = ?, 
        has_uncommon = ?, credit_balance = ?, initial_debt = ?, status = ? 
        WHERE id = ?");
    $stmt->execute([
        $data['code'], $data['type'], $data['towerBlock'], $data['floor'], 
        $data['number'], $data['aliquot'], $data['hasUncommonExpense'] ? 1 : 0, 
        $data['creditBalance'], $data['initialDebt'], $data['status'], $data['id']
    ]);
} else {
    // INSERT
    $stmt = $pdo->prepare("INSERT INTO properties 
        (code, type, tower, floor, number, aliquot, has_uncommon, credit_balance, initial_debt, status) 
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
    $stmt->execute([
        $data['code'], $data['type'], $data['towerBlock'], $data['floor'], 
        $data['number'], $data['aliquot'], $data['hasUncommonExpense'] ? 1 : 0, 
        $data['creditBalance'], $data['initialDebt'], $data['status']
    ]);
}

response(["success" => true]);
?>
```

# api/delete_property.php
```php
<?php
require_once 'config.php';

if (!isset($_SESSION['user_id']) || !in_array($_SESSION['user_role'], ['admin', 'programmer'])) {
    response(["error" => "No autorizado"], 401);
}

$data = json_decode(file_get_contents("php://input"), true);
$stmt = $pdo->prepare("DELETE FROM properties WHERE id = ?");
$stmt->execute([$data['id']]);

response(["success" => true]);
?>