update
This commit is contained in:
@@ -208,6 +208,8 @@
|
||||
<th>Date</th>
|
||||
<th>Warm</th>
|
||||
<th>LHe Delivery</th>
|
||||
<th>Vor</th>
|
||||
<th>Nach</th>
|
||||
<th>LHe Output</th>
|
||||
<th>Notes</th>
|
||||
<th>Actions</th>
|
||||
@@ -223,7 +225,9 @@
|
||||
<td>{{ entry.date }}</td>
|
||||
<td>{{ entry.is_warm|yesno:"Yes,No" }}</td>
|
||||
<td>{{ entry.lhe_delivery }}</td>
|
||||
<td>{{ entry.lhe_output }}</td>
|
||||
<td>{% if entry.vor is not None %}{{ entry.vor|floatformat:1 }}{% endif %}</td>
|
||||
<td>{% if entry.nach is not None %}{{ entry.nach|floatformat:1 }}{% endif %}</td>
|
||||
<td>{% if entry.lhe_output is not None %}{{ entry.lhe_output|floatformat:1 }}{% endif %}</td>
|
||||
<td>{{ entry.notes }}</td>
|
||||
<td class="actions">
|
||||
<button class="edit-btn-two">Edit</button>
|
||||
@@ -272,9 +276,19 @@
|
||||
<input type="text" id="add-lhe-delivery" placeholder="Enter delivery amount">
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="add-vor">Vor:</label>
|
||||
<input type="number" id="add-vor" step="0.1">
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="add-nach">Nach:</label>
|
||||
<input type="number" id="add-nach" step="0.1">
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="add-lhe-output">LHe Ausgabe:</label>
|
||||
<input type="number" id="add-lhe-output" placeholder="Enter output amount (numbers only)" step="0.01" min="0">
|
||||
<input type="number" id="add-lhe-output" readonly>
|
||||
</div>
|
||||
|
||||
<label for="add-notes">Notes:</label>
|
||||
@@ -326,9 +340,20 @@
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="edit-lhe-output">LHe Ausgabe:</label>
|
||||
<input type="number" id="edit-lhe-output" placeholder="Enter output amount">
|
||||
<label for="edit-vor">Vor:</label>
|
||||
<input type="number" id="edit-vor" step="0.1">
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="edit-nach">Nach:</label>
|
||||
<input type="number" id="edit-nach" step="0.1">
|
||||
</div>
|
||||
|
||||
<div class="input-with-label">
|
||||
<label for="edit-lhe-output">LHe Ausgabe:</label>
|
||||
<input type="number" id="edit-lhe-output" readonly>
|
||||
</div>
|
||||
|
||||
|
||||
<label for="edit-notes">Notes:</label>
|
||||
<textarea id="edit-notes" placeholder="Additional notes"></textarea>
|
||||
@@ -346,7 +371,30 @@
|
||||
// Store all client options for both dropdowns
|
||||
const allClientOptions = $('#add-client-id').html();
|
||||
const allEditClientOptions = $('#edit-client-id').html();
|
||||
function calculateAddOutput() {
|
||||
let vor = parseFloat($('#add-vor').val()) || 0;
|
||||
let nach = parseFloat($('#add-nach').val()) || 0;
|
||||
|
||||
let output = nach - vor;
|
||||
|
||||
if (output < 0) output = 0;
|
||||
|
||||
$('#add-lhe-output').val(output.toFixed(1));
|
||||
}
|
||||
|
||||
$('#add-vor, #add-nach').on('input', calculateAddOutput);
|
||||
function calculateEditOutput() {
|
||||
let vor = parseFloat($('#edit-vor').val()) || 0;
|
||||
let nach = parseFloat($('#edit-nach').val()) || 0;
|
||||
|
||||
let output = nach - vor;
|
||||
|
||||
if (output < 0) output = 0;
|
||||
|
||||
$('#edit-lhe-output').val(output.toFixed(1));
|
||||
}
|
||||
|
||||
$('#edit-vor, #edit-nach').on('input', calculateEditOutput);
|
||||
// Function to filter clients based on institute selection
|
||||
function filterClients(instituteId, targetSelect, allOptions) {
|
||||
if (!instituteId) {
|
||||
@@ -469,15 +517,21 @@
|
||||
}
|
||||
|
||||
let formData = {
|
||||
'client_id': clientId,
|
||||
'date': $('#add-date').val(),
|
||||
'is_warm': warmValue,
|
||||
'lhe_delivery': $('#add-lhe-delivery').val(),
|
||||
'lhe_output': $('#add-lhe-output').val(),
|
||||
'notes': $('#add-notes').val(),
|
||||
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
||||
};
|
||||
'client_id': clientId,
|
||||
'date': $('#add-date').val(),
|
||||
'is_warm': warmValue,
|
||||
'lhe_delivery': $('#add-lhe-delivery').val(),
|
||||
|
||||
// ✅ NEW: send vor/nach to backend
|
||||
'vor': $('#add-vor').val(),
|
||||
'nach': $('#add-nach').val(),
|
||||
|
||||
// ❌ DO NOT send lhe_output anymore (backend should compute it)
|
||||
// 'lhe_output': $('#add-lhe-output').val(),
|
||||
|
||||
'notes': $('#add-notes').val(),
|
||||
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
||||
};
|
||||
// Validate date format
|
||||
if (!formData.date) {
|
||||
alert('Please select a date');
|
||||
@@ -485,9 +539,16 @@
|
||||
}
|
||||
|
||||
// Validate LHe Output is a number
|
||||
if (formData.lhe_output && isNaN(parseFloat(formData.lhe_output))) {
|
||||
alert('LHe Output must be a valid number');
|
||||
return;
|
||||
const vorVal = $('#add-vor').val();
|
||||
const nachVal = $('#add-nach').val();
|
||||
|
||||
if (vorVal !== "" && isNaN(parseFloat(vorVal))) {
|
||||
alert('Vor must be a valid number');
|
||||
return;
|
||||
}
|
||||
if (nachVal !== "" && isNaN(parseFloat(nachVal))) {
|
||||
alert('Nach must be a valid number');
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
@@ -498,22 +559,25 @@
|
||||
if (response.status === 'success') {
|
||||
// Add the new row to the table
|
||||
let newRow = `
|
||||
<tr data-id="${response.id}">
|
||||
<td>${$('#table-two tbody tr').length + 1}</td>
|
||||
<td>${response.id}</td>
|
||||
<td>${response.institute_name || ''}</td>
|
||||
<td>${response.client_name}</td>
|
||||
<td>${response.date || ''}</td>
|
||||
<td>${response.is_warm ? 'Yes' : 'No'}</td>
|
||||
<td>${response.lhe_delivery}</td>
|
||||
<td>${response.lhe_output || ''}</td>
|
||||
<td>${response.notes || ''}</td>
|
||||
<td class="actions">
|
||||
<button class="edit-btn-two">Edit</button>
|
||||
<button class="delete-btn-two">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr data-id="${response.id}">
|
||||
<td>${$('#table-two tbody tr').length + 1}</td>
|
||||
<td>${response.id}</td>
|
||||
<td>${response.institute_name || ''}</td>
|
||||
<td>${response.client_name}</td>
|
||||
<td>${response.date || ''}</td>
|
||||
<td>${response.is_warm ? 'Yes' : 'No'}</td>
|
||||
<td>${response.lhe_delivery || ''}</td>
|
||||
<td>${response.vor ?? ''}</td>
|
||||
<td>${response.nach ?? ''}</td>
|
||||
<td>${response.lhe_output ?? ''}</td>
|
||||
<td>${response.notes || ''}</td>
|
||||
<td class="actions">
|
||||
<button class="edit-btn-two">Edit</button>
|
||||
<button class="delete-btn-two">Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
|
||||
$('#table-two tbody').append(newRow);
|
||||
$('#add-popup-two').fadeOut();
|
||||
} else {
|
||||
@@ -558,15 +622,16 @@
|
||||
|
||||
// Set other fields
|
||||
$('#edit-id').val(entryId);
|
||||
$('#edit-date').val(row.find('td:eq(3)').text().trim());
|
||||
|
||||
// Set warm value (convert from "Yes"/"No" to 1/0)
|
||||
const warmValue = row.find('td:eq(4)').text().trim() === 'Yes' ? 1 : 0;
|
||||
$('#edit-date').val(row.find('td:eq(4)').text().trim());
|
||||
|
||||
const warmValue = row.find('td:eq(5)').text().trim() === 'Yes' ? 1 : 0;
|
||||
$('#edit-is-warm').val(warmValue);
|
||||
|
||||
$('#edit-lhe-delivery').val(row.find('td:eq(5)').text().trim());
|
||||
$('#edit-lhe-output').val(row.find('td:eq(6)').text().trim());
|
||||
$('#edit-notes').val(row.find('td:eq(7)').text().trim());
|
||||
|
||||
$('#edit-lhe-delivery').val(row.find('td:eq(6)').text().trim());
|
||||
$('#edit-vor').val(row.find('td:eq(7)').text().trim());
|
||||
$('#edit-nach').val(row.find('td:eq(8)').text().trim());
|
||||
$('#edit-lhe-output').val(row.find('td:eq(9)').text().trim());
|
||||
$('#edit-notes').val(row.find('td:eq(10)').text().trim());
|
||||
|
||||
// Apply warm field logic
|
||||
handleWarmFieldChange($('#edit-is-warm'), $('#edit-lhe-delivery'));
|
||||
@@ -597,15 +662,22 @@
|
||||
}
|
||||
|
||||
let formData = {
|
||||
'id': $('#edit-id').val(),
|
||||
'client_id': clientId,
|
||||
'date': $('#edit-date').val(),
|
||||
'is_warm': warmValue,
|
||||
'lhe_delivery': $('#edit-lhe-delivery').val(),
|
||||
'lhe_output': $('#edit-lhe-output').val(),
|
||||
'notes': $('#edit-notes').val(),
|
||||
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
||||
};
|
||||
'id': $('#edit-id').val(),
|
||||
'client_id': clientId,
|
||||
'date': $('#edit-date').val(),
|
||||
'is_warm': warmValue,
|
||||
'lhe_delivery': $('#edit-lhe-delivery').val(),
|
||||
|
||||
// ✅ NEW
|
||||
'vor': $('#edit-vor').val(),
|
||||
'nach': $('#edit-nach').val(),
|
||||
|
||||
// ❌ DO NOT send lhe_output anymore
|
||||
// 'lhe_output': $('#edit-lhe-output').val(),
|
||||
|
||||
'notes': $('#edit-notes').val(),
|
||||
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
||||
};
|
||||
|
||||
// Validate inputs
|
||||
if (!formData.date) {
|
||||
@@ -623,13 +695,16 @@
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
let row = $(`tr[data-id="${response.id}"]`);
|
||||
row.find('td:eq(2)').text(response.client_name);
|
||||
row.find('td:eq(3)').text(response.date || '');
|
||||
row.find('td:eq(4)').text(response.is_warm ? 'Yes' : 'No');
|
||||
row.find('td:eq(5)').text(response.lhe_delivery);
|
||||
row.find('td:eq(6)').text(response.lhe_output || '');
|
||||
row.find('td:eq(7)').text(response.notes || '');
|
||||
let row = $(`tr[data-id="${response.id}"]`);
|
||||
row.find('td:eq(2)').text(response.institute_name || '');
|
||||
row.find('td:eq(3)').text(response.client_name || '');
|
||||
row.find('td:eq(4)').text(response.date || '');
|
||||
row.find('td:eq(5)').text(response.is_warm ? 'Yes' : 'No');
|
||||
row.find('td:eq(6)').text(response.lhe_delivery || '');
|
||||
row.find('td:eq(7)').text(response.vor ?? '');
|
||||
row.find('td:eq(8)').text(response.nach ?? '');
|
||||
row.find('td:eq(9)').text(response.lhe_output ?? '');
|
||||
row.find('td:eq(10)').text(response.notes || '');
|
||||
$('#edit-popup-two').fadeOut();
|
||||
} else {
|
||||
alert('Update failed: ' + (response.message || 'Unknown error'));
|
||||
|
||||
Reference in New Issue
Block a user