feat(treatment): date-range filter on treatment cases, and time on the start stamp
The list could be narrowed by status and by search but not by when a case opened, which is the one axis a clinic actually reports on. `from` and `to` (YYYY-MM-DD) now bound `opened_at`, using the same strtotime day-boundary convention the appointment date filters already use under the app's global Tehran timezone. A malformed value is ignored rather than erroring — this is a filter, not a form field. Both bounds live in the URL via useUrlState, so back and refresh keep the range. The two date inputs and the "تا" between them are one nowrap unit; letting them wrap separately orphaned the word from its field on a 390px screen. The card's "شروع" showed only the Jalali date, so several cases opened on the same day were indistinguishable on that line too. It now uses formatDateTime. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,10 +52,34 @@ class TreatmentCaseController extends BaseController
|
||||
|
||||
return $this->success(array_map(
|
||||
static fn (TreatmentCase $c): array => $c->toArray(),
|
||||
$this->cases->findForTenant($entityType, $entityId, $status, $q !== '' ? $q : null),
|
||||
$this->cases->findForTenant(
|
||||
$entityType,
|
||||
$entityId,
|
||||
$status,
|
||||
$q !== '' ? $q : null,
|
||||
$this->dayBoundary($request->query->get('from'), '00:00:00'),
|
||||
$this->dayBoundary($request->query->get('to'), '23:59:59'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* `YYYY-MM-DD` میلادی → ثانیهٔ ابتدای/انتهای همان روز.
|
||||
*
|
||||
* تایمزون سراسری اپلیکیشن تهران است (`config/bootstrap_tz.php`)، پس همان
|
||||
* `strtotime` که بقیهٔ فیلترهای تاریخِ نوبتها استفاده میکنند اینجا هم درست است.
|
||||
*/
|
||||
private function dayBoundary(mixed $value, string $time): ?int
|
||||
{
|
||||
if (!is_string($value) || !preg_match('/^\d{4}-\d{2}-\d{2}$/', $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ts = strtotime($value . ' ' . $time);
|
||||
|
||||
return $ts === false ? null : $ts;
|
||||
}
|
||||
|
||||
#[Route('/api/v1/treatment-case/{uuid}', name: 'treatment_case_show', methods: ['GET'])]
|
||||
public function show(#[CurrentUser] User $user, string $uuid): JsonResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user