<?php $pageTitle='Team Tasks'; ?>
<div class="page-heading"><div><p class="eyebrow">Team Portal</p><h1>Tasks & Follow-ups</h1><p>Assign operational, document, maintenance, accounting, and border follow-ups.</p></div></div><div class="content-grid two-col"><form class="panel form-stack" method="post" action="<?= url('/tasks/store') ?>"><?= csrf_field() ?><h2>New Task</h2><label><span>Title</span><input name="title" required></label><label><span>Assigned To</span><select name="assigned_to"><option value="">Unassigned</option><?php foreach($users as$u):?><option value="<?= e((string)$u['id']) ?>"><?= e($u['name'].' · '.readable_status($u['role'])) ?></option><?php endforeach;?></select></label><div class="form-grid two"><label><span>Priority</span><select name="priority"><option>normal</option><option>high</option><option>urgent</option><option>low</option></select></label><label><span>Due</span><input type="datetime-local" name="due_at"></label><label><span>Related Type</span><select name="related_type"><option value="">None</option><option>load</option><option>invoice</option><option>border_crossing</option><option>maintenance</option><option>driver</option></select></label><label><span>Related ID</span><input type="number" name="related_id"></label></div><label><span>Description</span><textarea name="description"></textarea></label><button class="btn btn-primary">Create Task</button></form><div class="panel"><div class="task-board"><?php foreach($tasks as$t):?><div class="task-card priority-<?= e($t['priority']) ?>"><div><span class="badge badge-<?= status_class($t['status']) ?>"><?= e(readable_status($t['status'])) ?></span><strong><?= e($t['title']) ?></strong><p><?= e($t['description']??'') ?></p><small><?= e($t['assignee_name']??'Unassigned') ?> · due <?= e(datetime_display($t['due_at'])) ?></small></div><form method="post" action="<?= url('/tasks/status') ?>" class="inline-form"><?= csrf_field() ?><input type="hidden" name="id" value="<?= e((string)$t['id']) ?>"><select name="status"><option>open</option><option>in_progress</option><option>blocked</option><option>completed</option></select><button class="btn btn-light btn-sm">Update</button></form></div><?php endforeach;?><?php if(!$tasks):?><p class="empty">No tasks assigned.</p><?php endif;?></div></div></div>
