369 lines
19 KiB
HTML
369 lines
19 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete {{ object.item_name }} - Inventory{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- BEGIN breadcrumb -->
|
|
<ol class="breadcrumb float-xl-end">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inventory:dashboard' %}">Inventory</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inventory:item_list' %}">Items</a></li>
|
|
<li class="breadcrumb-item active">Delete Confirmation</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Inventory Item
|
|
<small>Confirmation Required</small>
|
|
</h1>
|
|
<!-- END page-header -->
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">
|
|
<i class="fa fa-exclamation-triangle text-warning me-2"></i>
|
|
Confirm Item Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<!-- Warning Alert -->
|
|
<div class="alert alert-warning d-flex align-items-center mb-4">
|
|
<i class="fa fa-exclamation-triangle fa-2x me-3"></i>
|
|
<div>
|
|
<h6 class="alert-heading mb-1">Warning: Permanent Deletion</h6>
|
|
<p class="mb-0">You are about to permanently delete an inventory item. This action cannot be undone and may affect inventory tracking, purchase orders, and historical data.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Item Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<h6 class="mb-3">Item Details</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Item Code:</td>
|
|
<td><code>{{ object.item_code }}</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Item Name:</td>
|
|
<td>{{ object.item_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Category:</td>
|
|
<td>
|
|
<span class="badge bg-secondary">{{ object.get_category_display }}</span>
|
|
{% if object.subcategory %}
|
|
<br><small class="text-muted">{{ object.subcategory }}</small>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Item Type:</td>
|
|
<td>
|
|
<span class="badge bg-{{ object.get_item_type_color }}">{{ object.get_item_type_display }}</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Manufacturer:</td>
|
|
<td>{{ object.manufacturer|default:"Not specified" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="mb-3">Current Status</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Current Stock:</td>
|
|
<td>
|
|
<span class="fw-bold {% if object.current_stock > 0 %}text-success{% else %}text-muted{% endif %}">
|
|
{{ object.current_stock }} {{ object.get_unit_of_measure_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Total Value:</td>
|
|
<td class="fw-bold text-success">${{ object.total_value|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Active Status:</td>
|
|
<td>
|
|
<span class="badge bg-{{ object.is_active|yesno:'success,secondary' }}">
|
|
{{ object.is_active|yesno:'Active,Inactive' }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Created:</td>
|
|
<td>{{ object.created_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Last Updated:</td>
|
|
<td>{{ object.updated_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="alert alert-info mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-info-circle me-2"></i>Impact Assessment
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li><strong>Inventory Records:</strong> All stock records for this item will be permanently deleted</li>
|
|
<li><strong>Transaction History:</strong> All transaction history for this item will be lost</li>
|
|
<li><strong>Purchase Orders:</strong> May affect existing purchase orders that reference this item</li>
|
|
<li><strong>Reporting:</strong> Historical reports may show incomplete data</li>
|
|
{% if object.current_stock > 0 %}
|
|
<li><strong>Current Stock:</strong> <span class="text-warning fw-bold">{{ object.current_stock }} units will be removed from inventory</span></li>
|
|
{% endif %}
|
|
{% if object.controlled_substance %}
|
|
<li><strong>Controlled Substance:</strong> <span class="text-danger fw-bold">This is a controlled substance - deletion may affect compliance tracking</span></li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Stock Warning -->
|
|
{% if object.current_stock > 0 %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Stock Level Warning
|
|
</h6>
|
|
<p class="mb-2">This item currently has <strong>{{ object.current_stock }} {{ object.get_unit_of_measure_display }}</strong> in stock with a total value of <strong>${{ object.total_value|floatformat:2 }}</strong>.</p>
|
|
<p class="mb-0"><strong>Deleting this item will remove all stock from inventory without any transaction record.</strong></p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Controlled Substance Warning -->
|
|
{% if object.controlled_substance %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-shield-alt me-2"></i>Controlled Substance Alert
|
|
</h6>
|
|
<p class="mb-2">This item is classified as a controlled substance ({{ object.get_dea_schedule_display }}).</p>
|
|
<p class="mb-0"><strong>Deletion may affect DEA compliance tracking and audit trails. Ensure proper documentation before proceeding.</strong></p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Related Data Summary -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-primary">{{ stock_locations_count }}</div>
|
|
<div class="small text-muted">Stock Locations</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-info">{{ transaction_count }}</div>
|
|
<div class="small text-muted">Transactions</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-warning">{{ purchase_order_count }}</div>
|
|
<div class="small text-muted">Purchase Orders</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-secondary">{{ adjustment_count }}</div>
|
|
<div class="small text-muted">Adjustments</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card border-secondary mb-4">
|
|
<div class="card-header bg-light">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Consider these alternatives instead of deletion:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fa fa-ban text-warning me-2"></i>
|
|
<a href="{% url 'inventory:item_deactivate' object.pk %}" class="text-decoration-none">
|
|
Deactivate the item instead of deleting
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-edit text-primary me-2"></i>
|
|
<a href="{% url 'inventory:item_update' object.pk %}" class="text-decoration-none">
|
|
Edit item information
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fa fa-archive text-info me-2"></i>
|
|
Archive the item for historical reference
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-exchange-alt text-success me-2"></i>
|
|
Transfer stock to another item
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Confirmation Form -->
|
|
<form method="post" id="delete-form">
|
|
{% csrf_token %}
|
|
|
|
<div class="card border-danger">
|
|
<div class="card-header bg-danger text-white">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fa fa-trash me-2"></i>Deletion Confirmation
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-understanding" required>
|
|
<label class="form-check-label" for="confirm-understanding">
|
|
I understand that this action will permanently delete the inventory item and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-impact" required>
|
|
<label class="form-check-label" for="confirm-impact">
|
|
I acknowledge the impact on inventory records, transactions, and reporting
|
|
</label>
|
|
</div>
|
|
|
|
{% if object.current_stock > 0 %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-stock" required>
|
|
<label class="form-check-label" for="confirm-stock">
|
|
I acknowledge that {{ object.current_stock }} units of stock will be permanently removed from inventory
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.controlled_substance %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-controlled" required>
|
|
<label class="form-check-label" for="confirm-controlled">
|
|
I acknowledge that this is a controlled substance and understand the compliance implications
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
|
|
<select class="form-select" name="deletion_reason" required>
|
|
<option value="">Select reason...</option>
|
|
<option value="DUPLICATE_ITEM">Duplicate item</option>
|
|
<option value="INCORRECT_ENTRY">Incorrect entry</option>
|
|
<option value="DISCONTINUED">Item discontinued</option>
|
|
<option value="REPLACED">Replaced by another item</option>
|
|
<option value="DATA_CLEANUP">Data cleanup</option>
|
|
<option value="COMPLIANCE">Compliance requirement</option>
|
|
<option value="OTHER">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Additional Notes</label>
|
|
<textarea class="form-control" name="deletion_notes" rows="3"
|
|
placeholder="Provide additional details about why this deletion is necessary..."></textarea>
|
|
</div>
|
|
|
|
{% if object.current_stock > 0 %}
|
|
<div class="mb-3">
|
|
<label class="form-label">Stock Disposition <span class="text-danger">*</span></label>
|
|
<select class="form-select" name="stock_disposition" required>
|
|
<option value="">Select disposition...</option>
|
|
<option value="WRITE_OFF">Write off as loss</option>
|
|
<option value="TRANSFER">Transfer to another item</option>
|
|
<option value="RETURN">Return to supplier</option>
|
|
<option value="DISPOSE">Dispose/destroy</option>
|
|
<option value="OTHER">Other</option>
|
|
</select>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between mt-4">
|
|
<div>
|
|
<a href="{% url 'inventory:item_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
<a href="{% url 'inventory:item_deactivate' object.pk %}" class="btn btn-warning ms-2">
|
|
<i class="fa fa-ban me-2"></i>Deactivate Instead
|
|
</a>
|
|
</div>
|
|
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
|
|
<i class="fa fa-trash me-2"></i>Permanently Delete Item
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Enable/disable delete button based on checkboxes
|
|
function updateDeleteButton() {
|
|
var allChecked = true;
|
|
$('input[type="checkbox"][required]').each(function() {
|
|
if (!$(this).is(':checked')) {
|
|
allChecked = false;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
var reasonSelected = $('select[name="deletion_reason"]').val() !== '';
|
|
{% if object.current_stock > 0 %}
|
|
var stockDispositionSelected = $('select[name="stock_disposition"]').val() !== '';
|
|
{% else %}
|
|
var stockDispositionSelected = true;
|
|
{% endif %}
|
|
|
|
$('#delete-btn').prop('disabled', !(allChecked && reasonSelected && stockDispositionSelected));
|
|
}
|
|
|
|
// Check on checkbox change
|
|
$('input[type="checkbox"], select[name="deletion_reason"], select[name="stock_disposition"]').on('change', updateDeleteButton);
|
|
|
|
// Form submission confirmation
|
|
$('#delete-form').on('submit', function(e) {
|
|
var confirmText = 'Are you absolutely sure you want to permanently delete "{{ object.item_name }}"?';
|
|
{% if object.current_stock > 0 %}
|
|
confirmText += '\n\nThis will remove {{ object.current_stock }} units from inventory.';
|
|
{% endif %}
|
|
confirmText += '\n\nThis action cannot be undone.';
|
|
|
|
if (!confirm(confirmText)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
// Auto-focus on first checkbox
|
|
$('#confirm-understanding').focus();
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|