Files
IT_asset_management/app/templates/assets/form.html

161 lines
7.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends 'base.html' %}
{% block title %}{{ 'Edit Asset' if asset else 'New Asset' }} IT Asset Management{% endblock %}
{% block breadcrumb %}
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.index') }}">Home</a></li>
<li class="breadcrumb-item"><a href="{{ url_for('assets.index') }}">Assets</a></li>
<li class="breadcrumb-item active">{{ 'Edit' if asset else 'New Asset' }}</li>
{% endblock %}
{% block content %}
<div class="page-header mb-4">
<h1><i class="bi bi-laptop me-2"></i>{{ 'Edit Asset' if asset else 'Add Asset' }}</h1>
</div>
<div class="card border-0 shadow-sm" style="max-width:800px;">
<div class="card-body">
{% if not asset and prefill and prefill.service_tag %}
<div class="alert alert-info py-2 mb-3 small">
<i class="bi bi-cloud-check me-1"></i>
Pre-filled from Dell service tag <strong>{{ prefill.service_tag }}</strong>. Review the details below before saving.
</div>
{% endif %}
<form method="POST" action="{{ url_for('assets.edit', asset_id=asset.id) if asset else url_for('assets.create') }}">
<h6 class="text-uppercase text-muted mb-3 small">Identifiers</h6>
<div class="row g-3 mb-3">
<div class="col-md-4">
<label class="form-label">Serial Number <span class="text-danger">*</span></label>
<input type="text" name="serial_number" class="form-control"
value="{{ asset.serial_number if asset else (prefill.serial_number if prefill else '') }}" required>
</div>
<div class="col-md-4">
<label class="form-label">Service Tag</label>
<input type="text" name="service_tag" class="form-control"
value="{{ asset.service_tag or '' if asset else (prefill.service_tag if prefill else '') }}"
placeholder="e.g. Dell service tag">
</div>
<div class="col-md-4">
<label class="form-label">Asset Tag</label>
<input type="text" name="asset_tag" class="form-control"
value="{{ asset.asset_tag or '' if asset else '' }}"
placeholder="Internal barcode/tag">
</div>
</div>
<h6 class="text-uppercase text-muted mb-3 small">Classification</h6>
<div class="row g-3 mb-3">
<div class="col-md-4">
<label class="form-label">Asset Type <span class="text-danger">*</span></label>
<select name="asset_type" class="form-select" required>
{% for t in asset_types %}
<option value="{{ t }}"
{% if asset and asset.asset_type == t %}selected
{% elif not asset and prefill and prefill.asset_type == t %}selected
{% elif not asset and not prefill and t == 'Laptop' %}selected
{% endif %}>{{ t }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-4">
<label class="form-label">Brand</label>
<input type="text" name="brand" class="form-control"
value="{{ asset.brand or '' if asset else (prefill.brand if prefill else '') }}"
placeholder="e.g. Dell, Lenovo, HP">
</div>
<div class="col-md-4">
<label class="form-label">Model</label>
<input type="text" name="model" class="form-control"
value="{{ asset.model or '' if asset else (prefill.model if prefill else '') }}"
placeholder="e.g. Latitude 5540">
</div>
</div>
<h6 class="text-uppercase text-muted mb-3 small">Technical Specs</h6>
<div class="row g-3 mb-3">
<div class="col-md-6">
<label class="form-label">Processor</label>
<input type="text" name="processor" class="form-control"
value="{{ asset.processor or '' if asset else '' }}"
placeholder="e.g. Intel Core i5-1345U">
</div>
<div class="col-md-3">
<label class="form-label">RAM (GB)</label>
<input type="number" name="ram_gb" class="form-control" min="0"
value="{{ asset.ram_gb or '' if asset else '' }}">
</div>
<div class="col-md-3">
<label class="form-label">Storage (GB)</label>
<input type="number" name="storage_gb" class="form-control" min="0"
value="{{ asset.storage_gb or '' if asset else '' }}">
</div>
<div class="col-md-4">
<label class="form-label">Operating System</label>
<input type="text" name="operating_system" class="form-control"
value="{{ asset.operating_system or '' if asset else (prefill.operating_system if prefill else 'Windows 11 Pro') }}"
placeholder="e.g. Windows 11 Pro">
</div>
<div class="col-md-4">
<label class="form-label">MAC Address</label>
<input type="text" name="mac_address" class="form-control"
value="{{ asset.mac_address or '' if asset else '' }}">
</div>
<div class="col-md-4">
<label class="form-label">Location</label>
<input type="text" name="location" class="form-control"
value="{{ asset.location or '' if asset else '' }}">
</div>
</div>
<h6 class="text-uppercase text-muted mb-3 small">Procurement</h6>
<div class="row g-3 mb-3">
<div class="col-md-3">
<label class="form-label">Purchase Date</label>
<input type="date" name="purchase_date" class="form-control"
value="{{ asset.purchase_date.isoformat() if asset and asset.purchase_date else (prefill.purchase_date if prefill else '') }}">
</div>
<div class="col-md-3">
<label class="form-label">Warranty Expiry</label>
<input type="date" name="warranty_expiry" class="form-control"
value="{{ asset.warranty_expiry.isoformat() if asset and asset.warranty_expiry else (prefill.warranty_expiry if prefill else '') }}">
</div>
<div class="col-md-3">
<label class="form-label">Purchase Price</label>
<input type="number" name="purchase_price" class="form-control" step="0.01" min="0"
value="{{ asset.purchase_price or '' if asset else '' }}">
</div>
<div class="col-md-3">
<label class="form-label">Status</label>
<select name="status" class="form-select">
{% for val, label in asset_statuses %}
<option value="{{ val }}" {% if asset and asset.status == val %}selected{% elif not asset and val == 'available' %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-4">
<label class="form-label">Supplier</label>
<input type="text" name="supplier" class="form-control"
value="{{ asset.supplier or '' if asset else '' }}">
</div>
<div class="col-md-4">
<label class="form-label">PO Number</label>
<input type="text" name="po_number" class="form-control"
value="{{ asset.po_number or '' if asset else '' }}">
</div>
<div class="col-12">
<label class="form-label">Notes</label>
<textarea name="notes" class="form-control" rows="2">{{ asset.notes or '' if asset else '' }}</textarea>
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">
<i class="bi bi-check-lg me-1"></i>{{ 'Save Changes' if asset else 'Create Asset' }}
</button>
<a href="{{ url_for('assets.detail', asset_id=asset.id) if asset else url_for('assets.index') }}"
class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
{% endblock %}