New Changes

This commit is contained in:
2025-07-09 14:38:43 +02:00
parent 63556a1ac3
commit 16fd76ff5a
3 changed files with 126 additions and 109 deletions

Binary file not shown.

View File

@@ -64,6 +64,7 @@
font-size: 14px; font-size: 14px;
} }
.edit-btn { .edit-btn {
background-color: #28a745; background-color: #28a745;
color: white; color: white;
} }

View File

@@ -1,13 +1,14 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Helium Output</title> <title>Helium Output</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" /> <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" rel="stylesheet"/>
<style> <style>
body { body {
font-family: Arial, sans-serif; font-family: Arial, sans-serif;
margin: 0; margin: 0;
@@ -123,84 +124,90 @@
</style> </style>
</head> </head>
<body> <body>
<div class="d-flex justify-content-start mb-2">
<div class="d-flex justify-content-start mb-2"> <!-- "Go to Clients" button at top-left -->
<!-- "Go to Clients" button at top-left --> <a class="btn btn-outline-primary" href="{% url 'clients_list' %}">
<a href="{% url 'clients_list' %}" class="btn btn-outline-primary"> ⇦ Go to Clients
&#8678; Go to Clients
</a> </a>
</div> </div>
<h2>Helium Output</h2>
<h2>Helium Output</h2> <!-- Second Table -->
<div class="table-container">
<button class="add-row-btn" id="add-row-two">Add Row</button>
<table id="table-two">
<thead><tr><th>#</th><th>ID</th><th>Client</th><th>Date</th><th>Warm</th><th>LHe Anlieferung</th><th>LHe Ausgabe</th><th>Comments</th><th>Actions</th></tr></thead>
<!-- Second Table --> <tbody>
<div class="table-container">
<button class="add-row-btn" id="add-row-two">Add Row</button>
<table id="table-two">
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>Client</th>
<th>Entry 1</th>
<th>Entry 2</th>
<th>Date Joined</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entry in entries_table2 %} {% for entry in entries_table2 %}
<tr data-id="{{ entry.id }}"> <tr data-id="{{ entry.id }}">
<td>{{ forloop.counter }}</td> <td>{{ forloop.counter }}</td>
<td>{{ entry.id }}</td> <td>{{ entry.id }}</td>
<td>{{ entry.client.name }}</td> <td>{{ entry.client.name }}</td>
<td>{{ entry.age }}</td> <td>{{ entry.age }}</td>
<td>{{ entry.email }}</td> <td>{{ entry.email }}</td>
<td>{{ entry.date_joined }}</td> <td>{{ entry.date_joined }}</td>
<td class="actions"> <td class="actions">
<button class="edit-btn-two">Edit</button> <button class="edit-btn-two">Edit</button>
<button class="delete-btn-two">Delete</button> <button class="delete-btn-two">Delete</button>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
<!-- Add Entry Popup --> <!-- Add Entry Popup -->
<div id="add-popup-two" class="popup"> <div id="add-popup-two" class="popup" style="display:none;">
<span class="close-btn">&times;</span> <span class="close-btn">&times;</span>
<h3>Add Entry</h3> <h3>Add Entry</h3>
<select id="add-client-id"> <label for="add-client-id">Kunde:</label>
<select id="add-client-id">
{% for client in clients %}
<option value="{{ client.id }}">{{ client.name }}</option>
{% endfor %}
</select>
<label for="add-date">Datum:</label>
<input type="date" id="add-date">
<label><input type="checkbox" id="add-warm"> warm</label>
<label for="add-lhe-anlieferung">LHe Anlieferung:</label>
<input type="text" id="add-lhe-anlieferung" placeholder="LHe Anlieferung">
<label for="add-lhe-ausgabe">LHe Ausgabe:</label>
<input type="text" id="add-lhe-ausgabe" placeholder="LHe Ausgabe">
<label for="add-comment">Kommentar:</label>
<textarea id="add-comment" rows="4"></textarea>
<div style="margin-top: 10px;">
<button id="save-add-two">💾 Save</button>
<button class="close-btn">❌ Cancel</button>
<button id="help-btn">❓ Help</button>
</div>
</div>
</div>
<!-- Edit Entry Popup -->
<div class="popup" id="edit-popup-two">
<span class="close-btn">×</span>
<h3>Edit Entry</h3>
<input id="edit-id" type="hidden"/>
<label for="edit-client-id">Kunde:</label>
<select id="edit-client-id">
{% for client in clients %} {% for client in clients %}
<option value="{{ client.id }}">{{ client.name }}</option> <option value="{{ client.id }}">{{ client.name }}</option>
{% endfor %} {% endfor %}
</select> </select>
<input type="number" id="add-age" placeholder="Age"> <label><input id="edit-warm" type="checkbox"/> warm</label>
<input type="email" id="add-email" placeholder="Email"> <input id="edit-anlieferung" placeholder="LHe Anlieferung" type="text"/>
<button id="save-add-two">Add</button> <input id="edit-ausgabe" placeholder="LHe Ausgabe" type="text"/>
</div> <textarea id="edit-comments" placeholder="Comments" rows="4"></textarea>
<button id="save-edit-two">Save</button>
<!-- Edit Entry Popup --> <button class="close-btn">Cancel</button>
<div id="edit-popup-two" class="popup"> <button id="help-btn-edit-two">Help</button>
<span class="close-btn">&times;</span> </div>
<h3>Edit Entry</h3> <script>
<input type="hidden" id="edit-id">
<select id="edit-client-id">
{% for client in clients %}
<option value="{{ client.id }}">{{ client.name }}</option>
{% endfor %}
</select>
<input type="number" id="edit-age" placeholder="Age">
<input type="email" id="edit-email" placeholder="Email">
<button id="save-edit-two">Save</button>
</div>
<script>
$(document).ready(function () { $(document).ready(function () {
let currentTableId = null; // To track which table is being edited let currentTableId = null; // To track which table is being edited
let currentModelName = null; // To track which model is being used let currentModelName = null; // To track which model is being used
@@ -218,40 +225,50 @@
}); });
// Save Add Entry // Save Add Entry
$('#save-add-two').on('click', function () { $('#save-add-two').on('click', function () {
let client_id = $('#add-client-id').val(); // ✅ Correct variable let client_id = $('#add-client-id').val();
let age = $('#add-age').val(); let date = $('#add-date').val();
let email = $('#add-email').val(); let warm = $('#add-warm').is(':checked') ? 1 : 0;
let lhe_anlieferung = $('#add-lhe-anlieferung').val();
let lhe_ausgabe = $('#add-lhe-ausgabe').val();
let comment = $('#add-comment').val();
$.ajax({ $.ajax({
url: `/add-entry/${currentModelName}/`, url: '/add-entry/SecondTableEntry/',
method: 'POST', method: 'POST',
data: { data: {
'client_id': client_id, // ✅ REPLACE 'name' with this 'client_id': client_id,
'age': age, 'date': date,
'email': email, 'warm': warm,
'csrfmiddlewaretoken': '{{ csrf_token }}' 'lhe_anlieferung': lhe_anlieferung,
}, 'lhe_ausgabe': lhe_ausgabe,
success: function (response) { 'comment': comment,
let rowCount = $('#table-two tbody tr').length + 1; 'csrfmiddlewaretoken': '{{ csrf_token }}'
let newRow = ` },
<tr data-id="${response.id}"> success: function (response) {
<td>${rowCount}</td> <!-- Serial # --> let rowCount = $('tbody tr').length + 1;
<td>${response.id}</td> <!-- ID --> let newRow = `
<td>${response.client_name}</td> <!-- Name --> <tr data-id="${response.id}">
<td>${response.age}</td> <!-- Age --> <td>${rowCount}</td>
<td>${response.email}</td> <!-- Email --> <td>${response.id}</td>
<td>${response.date_joined}</td> <!-- Date Joined --> <td>${response.name}</td>
<td class="actions"> <!-- Actions --> <td>${response.warm}</td>
<button class="edit-btn-two">Edit</button> <td>${response.lhe_anlieferung}</td>
<button class="delete-btn-two">Delete</button> <td>${response.lhe_ausgabe}</td>
</td> <td>${response.date}</td>
</tr> <td class="actions">
`; <button class="edit-btn-two">Edit</button>
$(`#${currentTableId} tbody`).append(newRow); <button class="delete-btn-two">Delete</button>
$('#add-popup-two').fadeOut(); </td>
} </tr>`;
}); $('tbody').append(newRow);
$('#add-popup-two').fadeOut();
},
error: function (xhr) {
alert('Failed to add entry: ' + xhr.responseText);
}
});
});
}); });
// Open Edit Popup // Open Edit Popup
@@ -330,6 +347,5 @@
}); });
}); });
</script> </script>
</body> </body>
</html> </html>