@extends('layouts.app') @section('content') @php // ─── window navigation helpers ───────────────────────────────────── $endStr = $window_end->toDateString(); $prevEnd = $window_end->copy()->subDays($window_days)->toDateString(); $nextEnd = $window_end->copy()->addDays($window_days); // Don't allow paging into the future if ($nextEnd->gt(now())) { $nextEnd = now(); } $nextEndStr = $nextEnd->toDateString(); $isFuture = $window_end->copy()->addDays($window_days)->gt(now()); // Build a route helper for the current view that lets us swap one query param $base = ['end' => $endStr, 'days' => $window_days, 'search' => $search, 'adjustments_only' => $adjustments_only ? 1 : 0]; @endphp
Day-by-drug movement matrix · negative = stock out · red = adjustment
| Drug | @foreach($days as $day) @php $isWeekend = $day->isWeekend(); $isToday = $day->isToday(); @endphp
{{ $day->format('D') }}
{{ $day->format('d M') }}
|
@endforeach
Balance today | |
|---|---|---|---|
|
{{ $row['drug_name'] }}
{{ $row['drug_code'] }}
|
{{-- Cells: one per day --}}
@foreach($days as $day)
@php
$key = $day->toDateString();
$cell = $row['cells'][$key] ?? null;
@endphp
@if($cell === null)
· | @else @php $isAdj = $cell['kind'] === 'adjustment'; $isPositive = !$isAdj && $cell['net'] > 0; $cellBg = $isAdj ? 'bg-red-50' : ($isPositive ? 'bg-green-50' : ''); $textColor = $isAdj ? 'text-red-700 font-semibold' : ($cell['net'] > 0 ? 'text-green-700 font-semibold' : ($cell['net'] < 0 ? 'text-gray-800' : 'text-gray-400')); @endphp{{ $cell['net'] > 0 ? '+' : '' }}{{ number_format($cell['net']) }} @if($isAdj) ⚠ @endif | @endif @endforeach {{-- Balance --}}{{ number_format($row['balance_today']) }} |
| Daily net | @foreach($days as $day) @php $t = $totals[$day->toDateString()] ?? ['net'=>0,'in'=>0,'out'=>0]; @endphp
{{ $t['net'] > 0 ? '+' : '' }}{{ number_format($t['net']) }}
@if($t['in'] > 0) +{{ number_format($t['in']) }} @endif
@if($t['out'] < 0) {{ number_format($t['out']) }} @endif
|
@endforeach