2021-08-07 17:37:36 +02:00
|
|
|
{% extends 'base.html' %}
|
|
|
|
{% load qr_code %}
|
2021-10-29 21:18:20 +02:00
|
|
|
{% load static %}
|
2021-11-01 22:17:20 +01:00
|
|
|
{% load crispy_forms_tags %}
|
|
|
|
|
2021-08-07 17:37:36 +02:00
|
|
|
{% block content %}
|
|
|
|
<div class="container">
|
2021-08-14 00:25:19 +02:00
|
|
|
<nav aria-label="breadcrumb" class="fs-4">
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li class="breadcrumb-item"></li>
|
|
|
|
{% for crumb in breadcrumbs %}
|
|
|
|
<li class="breadcrumb-item"><a href="{% url 'parts-stocks-detail' uuid=crumb.id %}">{{crumb.name}}</a></li>
|
|
|
|
{% endfor %}
|
|
|
|
<li class="breadcrumb-item active" aria-current="page">{{object.name}}</li>
|
|
|
|
</ol>
|
|
|
|
</nav>
|
2021-08-07 17:37:36 +02:00
|
|
|
|
2021-08-14 00:25:19 +02:00
|
|
|
<div class="row">
|
2021-10-31 20:57:28 +01:00
|
|
|
<div class="col-md-3">
|
2021-11-07 20:36:12 +01:00
|
|
|
<div class="row">
|
2021-10-31 20:57:28 +01:00
|
|
|
{% qr_from_text object.get_qr_code size="m" image_format="svg" %}
|
|
|
|
</div>
|
2021-11-07 20:36:12 +01:00
|
|
|
<div class="row">
|
2021-10-31 20:57:28 +01:00
|
|
|
{% if object.parent_storage %}
|
|
|
|
<h1>Sub-Storages <a class="btn btn-secondary" href="{% url 'parts-stocks-detail' uuid=object.parent_storage.id %}">Parent Storage</a> {% else %}
|
|
|
|
<h1>Sub-Storages <a class="btn btn-secondary" href="{% url 'parts-stocks'%}">Stock Overview</a>
|
|
|
|
{% endif %}
|
|
|
|
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#delete-storage-modal">Delete</button>
|
|
|
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#add-sub-modal"><i class="bi bi-plus-circle"></i></button>
|
|
|
|
</h1>
|
|
|
|
<div class="list-group">
|
|
|
|
{% for storage in storages %}
|
|
|
|
<a href="{% url 'parts-stocks-detail' uuid=storage.id %}" class="text-decoration-none">
|
|
|
|
<li class="list-group-item list-group-item-action justify-content-between align-items-center d-flex">
|
|
|
|
<div>
|
|
|
|
<h5>{{storage.name}}</h5>
|
|
|
|
Responsible: {{ storage.responsible }}
|
|
|
|
</div>
|
|
|
|
<span class="badge bg-primary rounded-pill">{{storage.get_total_stock_amount}}</span>
|
|
|
|
</li>
|
|
|
|
</a>
|
|
|
|
{% endfor %}
|
|
|
|
</div>
|
|
|
|
{% include 'paginator.html' with paginator=storages get_param='storage_page' aria_label='Storage Page Navigation' %}
|
|
|
|
</div>
|
2021-08-14 00:25:19 +02:00
|
|
|
</div>
|
2021-11-07 20:36:12 +01:00
|
|
|
<div class="col">
|
2021-10-31 20:57:28 +01:00
|
|
|
<h1>Stocked Components</h1>
|
|
|
|
<form method="get">
|
2021-11-10 19:38:39 +01:00
|
|
|
<div class="input-group mb-3">
|
2021-10-31 20:57:28 +01:00
|
|
|
<input class="form-control" name="search" type="search" placeholder="Search..." {% if stock_search %}value="{{stock_search}}"{% endif %}>
|
|
|
|
<button type="submit" class="btn btn-primary">
|
|
|
|
<i class="bi bi-search"></i>
|
|
|
|
</button>
|
2021-11-14 18:40:21 +01:00
|
|
|
<button class="btn btn-success" type="button" data-bs-toggle="modal" data-bs-target="#add-stock-modal">
|
|
|
|
<i class="bi bi-plus-circle"></i> Add Stock
|
|
|
|
</button>
|
2021-10-31 20:57:28 +01:00
|
|
|
</div>
|
|
|
|
</form>
|
2022-01-02 20:00:29 +01:00
|
|
|
<div class="list-group mb-3">
|
2021-10-31 20:57:28 +01:00
|
|
|
{% for stock in stocks %}
|
|
|
|
<li class="list-group-item list-group-item-action d-flex align-items-center">
|
|
|
|
<div class="flex-shrink-0">
|
|
|
|
{% if stock.component.get_resolved_image %}
|
|
|
|
<img src="{{stock.component.get_resolved_image}}" style="max-width:64px;max-height:64px;" alt="{{ low.component.name }}" class="mr-3">
|
|
|
|
{% else %}
|
|
|
|
{% load static %}
|
|
|
|
<img src="{% static 'css/icons/card-image.svg' %}" style="width:64px;max-height:64px;" alt="{{ low.component.name }}" class="mr-3">
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
<div class="flex-grow-1 ms-3">
|
2022-02-21 19:45:42 +01:00
|
|
|
<h6 class="mt-0 text-primary"><a href="{% url 'parts-components-detail' uuid=stock.component.id %}" class="text-decoration-none">{{ stock.component.name }}</a>
|
|
|
|
{% for key_param in stock.component.get_key_parameters_as_text %}
|
|
|
|
{{key_param}}
|
|
|
|
{% endfor %}
|
|
|
|
</h6>
|
2021-10-31 20:57:28 +01:00
|
|
|
{% if stock.component.package %}
|
|
|
|
Package: {{stock.component.package}}<br>
|
|
|
|
{% endif %}
|
|
|
|
{% if stock.component.manufacturer %}
|
|
|
|
Manufacturer: {{stock.component.manufacturer}}
|
|
|
|
{% endif %}
|
2021-12-31 14:03:25 +01:00
|
|
|
{% if stock.lot %}
|
|
|
|
<span class="text-secondary"><br>Lot: {{stock.lot}}</span>
|
|
|
|
{% endif %}
|
2021-08-14 00:25:19 +02:00
|
|
|
</div>
|
2021-11-01 22:17:20 +01:00
|
|
|
<div class="ms-3">
|
|
|
|
Amount: {{stock.amount}}
|
|
|
|
{% if stock.watermark >= 0 %}
|
|
|
|
<br>Watermark: {{stock.watermark}}
|
|
|
|
{% else %}
|
|
|
|
<span class="text-secondary"><br>No Watermark</span>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
<div class="ms-3">
|
|
|
|
<button type="button" class="btn btn-secondary" data-bs-toggle="modal" data-bs-target="#change-stock-modal-{{stock.id}}">Change</button>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<form method="post">
|
|
|
|
{% csrf_token %}
|
|
|
|
<input type="hidden" name="stock_uuid" value="{{stock.id}}">
|
2021-12-31 14:03:25 +01:00
|
|
|
<input type="submit" class="btn btn-danger m-1" name="submit-delete-stock" value="X">
|
2021-11-01 22:17:20 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
2021-08-14 00:25:19 +02:00
|
|
|
</li>
|
2021-10-31 20:57:28 +01:00
|
|
|
{% endfor %}
|
2021-08-14 00:25:19 +02:00
|
|
|
</div>
|
2021-10-31 20:57:28 +01:00
|
|
|
{% include 'paginator.html' with paginator=stocks get_param='stock_page' aria_label='Stock Page Navigation' %}
|
2021-08-14 00:25:19 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-01 22:17:20 +01:00
|
|
|
{% for stock in stocks %}
|
|
|
|
{% include 'parts/modals/update-stock-modal.html' with stock=stock form=change_stock_form %}
|
|
|
|
{% endfor %}
|
2021-08-14 02:35:09 +02:00
|
|
|
<!-- Modal for adding a substorage-->
|
2021-10-24 21:14:11 +02:00
|
|
|
{% with add_storage_form as form %}
|
2021-10-25 19:31:50 +02:00
|
|
|
{% include 'parts/modals/new-substorage-modal.html' %}
|
2021-10-24 21:14:11 +02:00
|
|
|
{% endwith %}
|
2021-10-25 19:31:50 +02:00
|
|
|
<!-- Modal for deleting this storage -->
|
|
|
|
{% with delete_storage_errors as err_msgs %}
|
|
|
|
{% include 'parts/modals/delete-storage-modal.html' %}
|
|
|
|
{% endwith %}
|
2021-11-08 00:56:33 +01:00
|
|
|
<!-- Modal for adding stock to this storage -->
|
|
|
|
{% with add_stock_form as form %}
|
|
|
|
{% include 'parts/modals/add-stock-modal.html' %}
|
|
|
|
{% endwith %}
|
2021-10-25 19:31:50 +02:00
|
|
|
|
2021-08-07 17:37:36 +02:00
|
|
|
</div>
|
2021-10-24 21:14:11 +02:00
|
|
|
{% endblock content %}
|
|
|
|
|
|
|
|
{% block custom_scripts %}
|
2021-11-08 23:11:05 +01:00
|
|
|
<script type="text/javascript" src="{% static 'js/add-stock-modal.js' %}"></script>
|
2021-10-24 21:14:11 +02:00
|
|
|
<script type="text/javascript">
|
2021-10-29 21:18:20 +02:00
|
|
|
{% if add_storage_form.errors %}
|
|
|
|
|
2021-10-24 21:14:11 +02:00
|
|
|
var addSubStorageModal = document.querySelector('#add-sub-modal');
|
2021-10-25 19:31:50 +02:00
|
|
|
var c_modal = bootstrap.Modal.getOrCreateInstance(addSubStorageModal);
|
|
|
|
c_modal.show();
|
2021-10-24 21:14:11 +02:00
|
|
|
{% endif %}
|
2021-10-25 19:31:50 +02:00
|
|
|
{% if delete_storage_errors %}
|
|
|
|
var deleteStorageModal = document.querySelector('#delete-storage-modal');
|
|
|
|
var d_modal = bootstrap.Modal.getOrCreateInstance(deleteStorageModal);
|
|
|
|
d_modal.show();
|
|
|
|
{% endif %}
|
2021-11-08 23:11:05 +01:00
|
|
|
{% if add_stock_form.errors %}
|
|
|
|
var uuid = "{{add_stock_form.component_uuid.value}}";
|
|
|
|
if (uuid && uuid != '' && uuid != 'None') {
|
|
|
|
api_get_component_from_id(uuid, function(component){
|
|
|
|
var add_stock_modal_div = document.querySelector('#add-stock-modal');
|
|
|
|
var add_stock_modal = bootstrap.Modal.getOrCreateInstance(add_stock_modal_div);
|
|
|
|
fill_add_stock_modal_component(component);
|
|
|
|
add_stock_modal.show();
|
|
|
|
console.log(component)
|
|
|
|
}, function(){
|
|
|
|
var add_stock_modal_div = document.querySelector('#add-stock-modal');
|
|
|
|
var add_stock_modal = bootstrap.Modal.getOrCreateInstance(add_stock_modal_div);
|
|
|
|
add_stock_modal.show();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
var add_stock_modal_div = document.querySelector('#add-stock-modal');
|
|
|
|
var add_stock_modal = bootstrap.Modal.getOrCreateInstance(add_stock_modal_div);
|
|
|
|
add_stock_modal.show();
|
|
|
|
}
|
|
|
|
{% endif %}
|
2021-10-29 21:18:20 +02:00
|
|
|
|
|
|
|
new AutocompleteText('{{add_storage_form.responsible.id_for_label}}', '{{add_storage_form.responsible.id_for_label}}-ac-dropdown',
|
|
|
|
function(search, autocomplete_obj) {
|
|
|
|
api_search_user(search, function(results) {
|
|
|
|
var usernames = new Array();
|
|
|
|
console.log(results);
|
|
|
|
for (var i = 0; i < results.results.length; i++) {
|
|
|
|
usernames.push(results.results[i].username);
|
|
|
|
}
|
|
|
|
console.log(usernames);
|
|
|
|
autocomplete_obj.show_results(usernames);
|
|
|
|
}, function(){});
|
|
|
|
});
|
|
|
|
</script>
|
2021-10-24 21:14:11 +02:00
|
|
|
{% endblock custom_scripts %}
|
|
|
|
|