145 lines
5.7 KiB
HTML
145 lines
5.7 KiB
HTML
{% extends 'base.html' %}
|
||
{% block title %}Assignments – IT Asset Management{% endblock %}
|
||
{% block breadcrumb %}
|
||
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.index') }}">Home</a></li>
|
||
<li class="breadcrumb-item active">Assignments</li>
|
||
{% endblock %}
|
||
|
||
{% block content %}
|
||
<div class="page-header d-flex align-items-center justify-content-between mb-4">
|
||
<h1><i class="bi bi-arrow-left-right me-2"></i>Assignments</h1>
|
||
<a href="{{ url_for('assignments.create') }}" class="btn btn-primary btn-sm">
|
||
<i class="bi bi-plus-circle me-1"></i>Assign Asset
|
||
</a>
|
||
</div>
|
||
|
||
<form method="GET" class="row g-2 mb-3">
|
||
<div class="col-auto">
|
||
<div class="form-check form-check-inline mt-1">
|
||
<input class="form-check-input" type="checkbox" name="active" value="0" id="chkAll"
|
||
{% if not active_only %}checked{% endif %} onchange="this.form.submit()">
|
||
<label class="form-check-label" for="chkAll">Show returned</label>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
|
||
<div class="card border-0 shadow-sm">
|
||
<div class="table-responsive">
|
||
<table class="table table-hover mb-0">
|
||
<thead class="table-light">
|
||
<tr>
|
||
<th>User</th>
|
||
<th>Windows ID</th>
|
||
<th>Asset</th>
|
||
<th>Serial Number</th>
|
||
<th>Assigned</th>
|
||
<th>Returned</th>
|
||
<th>Status</th>
|
||
<th></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{% for a in pagination.items %}
|
||
<tr {% if a.user.is_masked %}class="masked-row"{% endif %}>
|
||
<td>
|
||
<a href="{{ url_for('users.detail', user_id=a.user.id) }}">{{ a.user.display_name }}</a>
|
||
</td>
|
||
<td><code>{{ a.user.windows_id }}</code></td>
|
||
<td>
|
||
<a href="{{ url_for('assets.detail', asset_id=a.asset.id) }}">
|
||
{{ a.asset.brand or '' }} {{ a.asset.model or '' }}
|
||
</a>
|
||
</td>
|
||
<td><code>{{ a.asset.serial_number }}</code></td>
|
||
<td>{{ a.assigned_date.strftime('%d/%m/%Y') if a.assigned_date else '—' }}</td>
|
||
<td>{{ a.returned_date.strftime('%d/%m/%Y') if a.returned_date else '—' }}</td>
|
||
<td>
|
||
{% if a.is_active %}
|
||
<span class="badge bg-success">Active</span>
|
||
{% else %}
|
||
<span class="badge bg-secondary">Returned</span>
|
||
{% endif %}
|
||
</td>
|
||
<td>
|
||
{% if a.is_active %}
|
||
<button class="btn btn-sm btn-outline-warning py-0 px-2"
|
||
data-bs-toggle="modal" data-bs-target="#returnModal{{ a.id }}">
|
||
<i class="bi bi-arrow-return-left"></i>
|
||
</button>
|
||
{% endif %}
|
||
<a href="{{ url_for('paperwork.create', assignment_id=a.id, user_id=a.user.id, asset_id=a.asset.id) }}"
|
||
class="btn btn-sm btn-outline-info py-0 px-2" title="Create document">
|
||
<i class="bi bi-file-earmark-plus"></i>
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
{% else %}
|
||
<tr><td colspan="8" class="text-center text-muted py-4">No assignments found.</td></tr>
|
||
{% endfor %}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
{% if pagination.pages > 1 %}
|
||
<div class="card-footer bg-white d-flex justify-content-between align-items-center py-2">
|
||
<small class="text-muted">Showing {{ pagination.first }}–{{ pagination.last }} of {{ pagination.total }}</small>
|
||
<nav>
|
||
<ul class="pagination pagination-sm mb-0">
|
||
{% if pagination.has_prev %}
|
||
<li class="page-item">
|
||
<a class="page-link" href="{{ url_for('assignments.index', page=pagination.prev_num, active='0' if not active_only else '1') }}">‹</a>
|
||
</li>
|
||
{% endif %}
|
||
{% for p in pagination.iter_pages() %}
|
||
{% if p %}
|
||
<li class="page-item {% if p == pagination.page %}active{% endif %}">
|
||
<a class="page-link" href="{{ url_for('assignments.index', page=p, active='0' if not active_only else '1') }}">{{ p }}</a>
|
||
</li>
|
||
{% else %}
|
||
<li class="page-item disabled"><span class="page-link">…</span></li>
|
||
{% endif %}
|
||
{% endfor %}
|
||
{% if pagination.has_next %}
|
||
<li class="page-item">
|
||
<a class="page-link" href="{{ url_for('assignments.index', page=pagination.next_num, active='0' if not active_only else '1') }}">›</a>
|
||
</li>
|
||
{% endif %}
|
||
</ul>
|
||
</nav>
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
|
||
<!-- Return modals -->
|
||
{% for a in pagination.items %}{% if a.is_active %}
|
||
<div class="modal fade" id="returnModal{{ a.id }}" tabindex="-1">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h5 class="modal-title">Return Asset</h5>
|
||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||
</div>
|
||
<form method="POST" action="{{ url_for('assignments.return_asset', assignment_id=a.id) }}">
|
||
<div class="modal-body">
|
||
<p>Returning <strong>{{ a.asset.serial_number }}</strong> from
|
||
<strong>{{ a.user.display_name }}</strong>.</p>
|
||
<div class="mb-3">
|
||
<label class="form-label">Return Date</label>
|
||
<input type="date" name="returned_date" class="form-control" required>
|
||
</div>
|
||
<div class="mb-0">
|
||
<label class="form-label">Notes</label>
|
||
<textarea name="return_notes" class="form-control" rows="2"></textarea>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||
<button type="submit" class="btn btn-warning">Confirm Return</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{% endif %}{% endfor %}
|
||
{% endblock %}
|