38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
require __DIR__ . '/_bootstrap.php';
|
|
|
|
/**
|
|
* @OA\Get(
|
|
* path="/home-owners.php",
|
|
* tags={"Owners"},
|
|
* summary="Home owners with shares",
|
|
* security={{"bearerAuth":{}}},
|
|
* @OA\Parameter(name="idhome", in="query", required=true, @OA\Schema(type="integer")),
|
|
* @OA\Response(response=200, description="OK", @OA\JsonContent(
|
|
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/HomeOwner"))
|
|
* )),
|
|
* @OA\Response(response=403, ref="#/components/responses/Forbidden")
|
|
* )
|
|
*/
|
|
require_method('GET');
|
|
$user = require_auth($pdo);
|
|
$idhome = (int) query('idhome', 0);
|
|
|
|
if ($idhome <= 0) {
|
|
json_error(422, 'idhome is required');
|
|
}
|
|
if (!user_can_access_home($pdo, $user, $idhome)) {
|
|
json_error(403, 'No access to this home');
|
|
}
|
|
|
|
$stmt = $pdo->prepare(
|
|
'SELECT po.*, ho.ownership_percentage, ho.notes
|
|
FROM home_owners ho
|
|
JOIN property_owners po ON po.owner_id = ho.owner_id
|
|
WHERE ho.home_id = ?
|
|
ORDER BY po.last_name, po.company_name'
|
|
);
|
|
$stmt->execute([$idhome]);
|
|
|
|
json_data(array_map('present_home_owner', $stmt->fetchAll()));
|