This commit is contained in:
2026-01-06 11:52:03 +01:00
parent b74cf45c5c
commit 34f040df30
11 changed files with 1027 additions and 264 deletions

View File

@@ -15,11 +15,12 @@
background-color: #f4f4f9;
}
.table-container {
width: 48%;
width: 100%;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
overflow-x: auto;
}
h2 {
text-align: center;
@@ -34,15 +35,23 @@
padding: 12px;
text-align: center;
border-bottom: 1px solid #ddd;
word-wrap: break-word;
}
th:nth-child(1), td:nth-child(1) { width: 5%; } /* # column */
th:nth-child(2), td:nth-child(2) { width: 5%; } /* ID column */
th:nth-child(3), td:nth-child(3) { width: 15%; } /* Client column */
th:nth-child(4), td:nth-child(4) { width: 10%; } /* Entry 1 (Pressure) */
th:nth-child(5), td:nth-child(5) { width: 10%; } /* Entry 2 (Purity) */
th:nth-child(6), td:nth-child(6) { width: 15%; } /* Date Joined */
th:nth-child(7), td:nth-child(7) { width: 25%; } /* Notes */
th:nth-child(7), td:nth-child(7) { width: 30%; } /* Actions */
th:nth-child(1), td:nth-child(1) { width: 3%; } /* # column */
th:nth-child(2), td:nth-child(2) { width: 3%; } /* ID column */
th:nth-child(3), td:nth-child(3) { width: 8%; } /* Institute */
th:nth-child(4), td:nth-child(4) { width: 8%; } /* Client */
th:nth-child(5), td:nth-child(5) { width: 5%; } /* Druck */
th:nth-child(6), td:nth-child(6) { width: 5%; } /* Reinheit */
th:nth-child(7), td:nth-child(7) { width: 5%; } /* Druckkorrektur */
th:nth-child(8), td:nth-child(8) { width: 6%; } /* ges. Flasch. Inhalt */
th:nth-child(9), td:nth-child(9) { width: 6%; } /* Korrig. Druck */
th:nth-child(10), td:nth-child(10) { width: 5%; } /* Nm³ */
th:nth-child(11), td:nth-child(11) { width: 5%; } /* L-He */
th:nth-child(12), td:nth-child(12) { width: 5%; } /* L-He zus. */
th:nth-child(13), td:nth-child(13) { width: 6%; } /* L-He ges. */
th:nth-child(14), td:nth-child(14) { width: 6%; } /* Date Joined */
th:nth-child(15), td:nth-child(15) { width: 8%; } /* Actions */
.actions {
white-space: nowrap; /* Prevent buttons from wrapping */
@@ -84,23 +93,58 @@
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
z-index: 1000;
width: 500px;
max-height: 90vh;
overflow-y: auto;
}
.popup input, .popup select {
.popup h3 {
margin-top: 0;
border-bottom: 1px solid #ddd;
padding-bottom: 10px;
}
.popup label {
display: block;
margin-bottom: 10px;
margin-bottom: 5px;
font-weight: bold;
}
.popup input, .popup select, .popup textarea {
display: block;
margin-bottom: 15px;
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.popup textarea {
height: 100px;
resize: vertical;
}
.popup-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
}
.popup button {
margin-top: 10px;
padding: 8px 16px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
.save-btn {
background-color: #28a745;
color: white;
}
.cancel-btn {
background-color: #6c757d;
color: white;
}
.help-btn {
background-color: #17a2b8;
color: white;
}
.close-btn {
cursor: pointer;
float: right;
@@ -120,7 +164,34 @@
.add-row-btn:hover {
background-color: #0056b3;
}
.input-with-label {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.input-with-label label {
width: 150px;
margin-bottom: 0;
margin-right: 10px;
}
.input-with-label input {
flex: 1;
margin-bottom: 0;
}
.formula-display {
background-color: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 4px;
padding: 8px;
margin-bottom: 15px;
font-size: 12px;
color: #6c757d;
font-style: italic;
}
.readonly-field {
background-color: #e9ecef;
color: #6c757d;
}
</style>
</head>
<body>
@@ -133,64 +204,96 @@
<div class="table-container">
<button class="add-row-btn" id="add-row-one">Add Row</button>
<table id="table-one">
<colgroup>
<col style="width: 5%"> <!-- # -->
<col style="width: 5%"> <!-- ID -->
<col style="width: 15%"> <!-- Client -->
<col style="width: 10%"> <!-- Druck -->
<col style="width: 10%"> <!-- Reinheit -->
<col style="width: 15%"> <!-- Date Joined -->
<col style="width: 25%"> <!-- Notes -->
<col style="width: 15%"> <!-- Actions -->
</colgroup>
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>Client</th>
<th>Druck</th>
<th>Reinheit</th>
<th>Date Joined</th>
<th>Notes</th>
<th>Actions</th>
<colgroup>
<col style="width: 3%"> <!-- # -->
<col style="width: 3%"> <!-- ID -->
<col style="width: 8%"> <!-- Institute -->
<col style="width: 8%"> <!-- Client -->
<col style="width: 5%"> <!-- Druck -->
<col style="width: 5%"> <!-- Reinheit -->
<col style="width: 5%"> <!-- Druckkorrektur -->
<col style="width: 6%"> <!-- ges. Flasch. Inhalt -->
<col style="width: 6%"> <!-- Korrig. Druck -->
<col style="width: 5%"> <!-- Nm³ -->
<col style="width: 5%"> <!-- L-He -->
<col style="width: 5%"> <!-- L-He zus. -->
<col style="width: 6%"> <!-- L-He ges. -->
<col style="width: 6%"> <!-- Date Joined -->
<col style="width: 8%"> <!-- Actions -->
</colgroup>
<thead>
<tr>
<th>#</th>
<th>ID</th>
<th>Institute</th>
<th>Client</th>
<th>Druck</th>
<th>Reinheit</th>
<th>Druckkorrektur</th>
<th>ges. Flasch. Inhalt</th>
<th>Korrig. Druck</th>
<th>Nm³</th>
<th>L-He</th>
<th>L-He zus.</th>
<th>L-He ges.</th>
<th>Date Joined</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for entry in entries_table1 %}
<tr data-id="{{ entry.id }}">
<td>{{ forloop.counter }}</td>
<td>{{ entry.id }}</td>
<td>{{ entry.client.institute.name }}</td>
<td>{{ entry.client.name }}</td>
<td>{{ entry.pressure|floatformat:2 }}</td>
<td>{{ entry.purity|floatformat:2 }}</td>
<td>{{ entry.druckkorrektur|floatformat:3 }}</td>
<td>{{ entry.constant_300|floatformat:3 }}</td>
<td>{{ entry.korrig_druck|floatformat:6 }}</td>
<td>{{ entry.nm3|floatformat:6 }}</td>
<td>{{ entry.lhe|floatformat:6 }}</td>
<td>{{ entry.lhe_zus|floatformat:3 }}</td>
<td>{{ entry.lhe_ges|floatformat:6 }}</td>
<td>{{ entry.date_joined|date:"Y-m-d" }}</td>
<td class="actions">
<button class="edit-btn-one">Edit</button>
<button class="delete-btn-one">Delete</button>
</td>
</tr>
</thead>
<tbody>
{% for entry in entries_table1 %}
<tr data-id="{{ entry.id }}">
<td>{{ forloop.counter }}</td>
<td>{{ entry.id }}</td>
<td>{{ entry.client.name }}</td>
<td>{{ entry.pressure|floatformat:2 }}</td>
<td>{{ entry.purity|floatformat:2 }}</td>
<td>{{ entry.date_joined|date:"Y-m-d" }}</td>
<td>{{ entry.notes|default:"" }}</td>
<td class="actions">
<button class="edit-btn-one">Edit</button>
<button class="delete-btn-one">Delete</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</tbody>
</table>
</div>
<!-- Add Popup -->
<div id="add-popup-one" class="popup">
<span class="close-btn">&times;</span>
<h3>He Gas Bundle</h3>
<!-- Institute Selection -->
<label for="add-institute-id">Institute:</label>
<select id="add-institute-id">
<option value="">Select Institute</option>
{% for institute in institutes %}
<option value="{{ institute.id }}">{{ institute.name }}</option>
{% endfor %}
</select>
<!-- Client Selection -->
<label for="add-client-id">Kunde:</label>
<select id="add-client-id">
<select id="add-client-id" disabled>
<option value="">Select Institute first</option>
{% for client in clients %}
<option value="{{ client.id }}">{{ client.name }}</option>
<option value="{{ client.id }}" data-institute="{{ client.institute.id }}">{{ client.name }}</option>
{% endfor %}
</select>
<label for="add-date">Date:</label>
<input type="date" id="add-date">
<!-- Manual Input Fields -->
<div class="input-with-label">
<label for="add-pressure">Druck:</label>
<input type="number" id="add-pressure" placeholder="Enter pressure" step="0.01" min="0">
@@ -201,8 +304,46 @@
<input type="number" id="add-purity" placeholder="Enter purity" step="0.01" min="0" max="100">
</div>
<label for="add-notes">Notes:</label>
<textarea id="add-notes" placeholder="Additional notes"></textarea>
<div class="input-with-label">
<label for="add-druckkorrektur">Druckkorrektur:</label>
<input type="number" id="add-druckkorrektur" placeholder="Enter Druckkorrektur" step="0.001" min="0" value="1.0">
</div>
<div class="input-with-label">
<label for="add-lhe-zus">L-He zus.:</label>
<input type="number" id="add-lhe-zus" placeholder="Enter L-He zus." step="0.001" min="0" value="0.0">
</div>
<!-- Auto-calculated Fields with Formulas -->
<div class="input-with-label">
<label for="add-constant-300">ges. Flasch. Inhalt:</label>
<input type="number" id="add-constant-300" value="300.000" step="0.001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Fixed value (300)</div>
<div class="input-with-label">
<label for="add-korrig-druck">Korrig. Druck:</label>
<input type="number" id="add-korrig-druck" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Druck * Druckkorrektur / ((Druck * Druckkorrektur) / 2000 + 1)</div>
<div class="input-with-label">
<label for="add-nm3">Nm³:</label>
<input type="number" id="add-nm3" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: (ges. Flasch. Inhalt * Korrig. Druck) / 1000</div>
<div class="input-with-label">
<label for="add-lhe">L-He:</label>
<input type="number" id="add-lhe" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Nm³ * (1 - Reinheit/100) / 0.75</div>
<div class="input-with-label">
<label for="add-lhe-ges">L-He ges.:</label>
<input type="number" id="add-lhe-ges" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: L-He zus. + L-He</div>
<div class="popup-buttons">
<button class="save-btn" id="save-add-one">Save</button>
@@ -217,16 +358,28 @@
<h3>He Gas Bundle</h3>
<input type="hidden" id="edit-id">
<!-- Institute Selection -->
<label for="edit-institute-id">Institute:</label>
<select id="edit-institute-id">
<option value="">Select Institute</option>
{% for institute in institutes %}
<option value="{{ institute.id }}">{{ institute.name }}</option>
{% endfor %}
</select>
<!-- Client Selection -->
<label for="edit-client-id">Kunde:</label>
<select id="edit-client-id">
<select id="edit-client-id" disabled>
<option value="">Select Institute first</option>
{% for client in clients %}
<option value="{{ client.id }}">{{ client.name }}</option>
<option value="{{ client.id }}" data-institute="{{ client.institute.id }}">{{ client.name }}</option>
{% endfor %}
</select>
<label for="edit-date">Date:</label>
<input type="date" id="edit-date">
<!-- Manual Input Fields -->
<div class="input-with-label">
<label for="edit-pressure">Druck:</label>
<input type="number" id="edit-pressure" placeholder="Enter pressure" step="0.01" min="0">
@@ -237,8 +390,46 @@
<input type="number" id="edit-purity" placeholder="Enter purity" step="0.01" min="0" max="100">
</div>
<label for="edit-notes">Notes:</label>
<textarea id="edit-notes" placeholder="Additional notes"></textarea>
<div class="input-with-label">
<label for="edit-druckkorrektur">Druckkorrektur:</label>
<input type="number" id="edit-druckkorrektur" placeholder="Enter Druckkorrektur" step="0.001" min="0" value="1.0">
</div>
<div class="input-with-label">
<label for="edit-lhe-zus">L-He zus.:</label>
<input type="number" id="edit-lhe-zus" placeholder="Enter L-He zus." step="0.001" min="0" value="0.0">
</div>
<!-- Auto-calculated Fields with Formulas -->
<div class="input-with-label">
<label for="edit-constant-300">ges. Flasch. Inhalt:</label>
<input type="number" id="edit-constant-300" value="300.000" step="0.001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Fixed value (300)</div>
<div class="input-with-label">
<label for="edit-korrig-druck">Korrig. Druck:</label>
<input type="number" id="edit-korrig-druck" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Druck * Druckkorrektur / ((Druck * Druckkorrektur) / 2000 + 1)</div>
<div class="input-with-label">
<label for="edit-nm3">Nm³:</label>
<input type="number" id="edit-nm3" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: (ges. Flasch. Inhalt * Korrig. Druck) / 1000</div>
<div class="input-with-label">
<label for="edit-lhe">L-He:</label>
<input type="number" id="edit-lhe" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: Nm³ * (1 - Reinheit/100) / 0.75</div>
<div class="input-with-label">
<label for="edit-lhe-ges">L-He ges.:</label>
<input type="number" id="edit-lhe-ges" step="0.000001" readonly class="readonly-field">
</div>
<div class="formula-display">Formula: L-He zus. + L-He</div>
<div class="popup-buttons">
<button class="save-btn" id="save-edit-one">Save</button>
@@ -252,16 +443,127 @@
let currentTableId = 'table-one';
let currentModelName = 'ExcelEntry';
// Store all client options for both dropdowns
const allClientOptions = $('#add-client-id').html();
const allEditClientOptions = $('#edit-client-id').html();
// Function to filter clients based on institute selection
function filterClients(instituteId, targetSelect, allOptions) {
if (!instituteId) {
// Show only the default option if no institute selected
targetSelect.html('<option value="">Select Institute first</option>');
targetSelect.prop('disabled', true);
} else {
// Restore all options first
targetSelect.html(allOptions);
// Enable the dropdown
targetSelect.prop('disabled', false);
// Hide all options first
targetSelect.find('option').hide();
// Always show the "Select Client" option
targetSelect.find('option[value=""]').show().text('Select Client');
// Show only clients from selected institute
const clientsFromInstitute = targetSelect.find(`option[data-institute="${instituteId}"]`);
if (clientsFromInstitute.length > 0) {
clientsFromInstitute.show();
} else {
targetSelect.html('<option value="">No clients found for this institute</option>');
}
// Reset selection
targetSelect.val('');
}
}
// Function to calculate all derived values
function calculateDerivedValues(prefix) {
const pressure = parseFloat($(`#${prefix}-pressure`).val()) || 0;
const purity = parseFloat($(`#${prefix}-purity`).val()) || 0;
const druckkorrektur = parseFloat($(`#${prefix}-druckkorrektur`).val()) || 1.0;
const lheZus = parseFloat($(`#${prefix}-lhe-zus`).val()) || 0;
const gesFlaschInhalt = parseFloat($(`#${prefix}-constant-300`).val()) || 300.0;
// Calculate Korrig. Druck
const korrigDruck = pressure * druckkorrektur / ((pressure * druckkorrektur) / 2000 + 1);
$(`#${prefix}-korrig-druck`).val(korrigDruck.toFixed(6));
// Calculate Nm³ - Updated to divide by 1000
const nm3 = (gesFlaschInhalt * korrigDruck) / 1000;
$(`#${prefix}-nm3`).val(nm3.toFixed(6));
// Calculate L-He
const lhe = nm3 * (1 - purity/100) / 0.75;
$(`#${prefix}-lhe`).val(lhe.toFixed(6));
// Calculate L-He ges.
const lheGes = lheZus + lhe;
$(`#${prefix}-lhe-ges`).val(lheGes.toFixed(6));
}
// Institute change handler for add popup
$('#add-institute-id').on('change', function() {
const instituteId = $(this).val();
filterClients(instituteId, $('#add-client-id'), allClientOptions);
});
// Institute change handler for edit popup
$('#edit-institute-id').on('change', function() {
const instituteId = $(this).val();
filterClients(instituteId, $('#edit-client-id'), allEditClientOptions);
});
// Add event listeners for calculation triggers in add popup
$('#add-pressure, #add-purity, #add-druckkorrektur, #add-lhe-zus').on('input change', function() {
calculateDerivedValues('add');
});
// Add event listeners for calculation triggers in edit popup
$('#edit-pressure, #edit-purity, #edit-druckkorrektur, #edit-lhe-zus').on('input change', function() {
calculateDerivedValues('edit');
});
$('#add-row-one').on('click', function () {
// Reset form
$('#add-institute-id').val('');
$('#add-client-id').html('<option value="">Select Institute first</option>');
$('#add-client-id').prop('disabled', true);
$('#add-date').val('');
$('#add-pressure').val('');
$('#add-purity').val('');
$('#add-druckkorrektur').val('1.0');
$('#add-lhe-zus').val('0.0');
$('#add-constant-300').val('300.000');
$('#add-korrig-druck').val('');
$('#add-nm3').val('');
$('#add-lhe').val('');
$('#add-lhe-ges').val('');
$('#add-popup-one').fadeIn();
});
$('.close-btn').on('click', function () {
$('.close-btn, .cancel-btn').on('click', function () {
$('.popup').fadeOut();
});
// Add
$('#save-add-one').on('click', function() {
const clientId = $('#add-client-id').val();
const instituteId = $('#add-institute-id').val();
if (!instituteId) {
alert('Please select an institute');
return;
}
if (!clientId) {
alert('Please select a client');
return;
}
// Validate date first
let dateInput = $('#add-date').val();
if (!dateInput) {
@@ -272,6 +574,9 @@
// Validate numbers
let pressure = parseFloat($('#add-pressure').val());
let purity = parseFloat($('#add-purity').val());
let druckkorrektur = parseFloat($('#add-druckkorrektur').val()) || 1.0;
let lheZus = parseFloat($('#add-lhe-zus').val()) || 0;
let gesFlaschInhalt = parseFloat($('#add-constant-300').val()) || 300.0;
if (isNaN(pressure) || pressure < 0) {
alert('Please enter a valid pressure value');
@@ -283,13 +588,37 @@
return;
}
if (isNaN(druckkorrektur) || druckkorrektur < 0) {
alert('Please enter a valid Druckkorrektur value');
return;
}
if (isNaN(lheZus) || lheZus < 0) {
alert('Please enter a valid L-He zus. value');
return;
}
// Calculate final values
calculateDerivedValues('add');
const korrigDruck = parseFloat($('#add-korrig-druck').val()) || 0;
const nm3 = parseFloat($('#add-nm3').val()) || 0;
const lhe = parseFloat($('#add-lhe').val()) || 0;
const lheGes = parseFloat($('#add-lhe-ges').val()) || 0;
// Prepare the form data
let formData = {
'client_id': $('#add-client-id').val(),
'client_id': clientId,
'date': dateInput,
'pressure': pressure,
'purity': purity,
'notes': $('#add-notes').val(),
'druckkorrektur': druckkorrektur,
'lhe_zus': lheZus,
'constant_300': gesFlaschInhalt,
'korrig_druck': korrigDruck,
'nm3': nm3,
'lhe': lhe,
'lhe_ges': lheGes,
'csrfmiddlewaretoken': '{{ csrf_token }}'
};
@@ -304,11 +633,18 @@
<tr data-id="${response.id}">
<td>${$('#table-one tbody tr').length + 1}</td>
<td>${response.id}</td>
<td>${response.institute_name || ''}</td>
<td>${response.client_name}</td>
<td>${response.pressure}</td>
<td>${response.purity}</td>
<td>${response.druckkorrektur}</td>
<td>${response.constant_300}</td>
<td>${response.korrig_druck}</td>
<td>${response.nm3}</td>
<td>${response.lhe}</td>
<td>${response.lhe_zus}</td>
<td>${response.lhe_ges}</td>
<td>${response.date || ''}</td>
<td>${response.notes || ''}</td>
<td class="actions">
<button class="edit-btn-one">Edit</button>
<button class="delete-btn-one">Delete</button>
@@ -328,32 +664,120 @@
});
// Edit
$(document).on('click', '.edit-btn-one', function() {
$(document).on('click', '.edit-btn-one', function() {
let row = $(this).closest('tr');
$('#edit-id').val(row.data('id'));
$('#edit-client-id').val(row.find('td:eq(2)').text().trim());
const entryId = row.data('id');
const clientName = row.find('td:eq(2)').text().trim();
// Reset edit form first
$('#edit-institute-id').val('');
$('#edit-client-id').html(allEditClientOptions);
$('#edit-client-id').prop('disabled', true);
// Find the client and set the institute
const clientOptions = $('#edit-client-id option');
let foundInstituteId = '';
let foundClientId = '';
clientOptions.each(function() {
if ($(this).text() === clientName) {
foundInstituteId = $(this).data('institute');
foundClientId = $(this).val();
return false; // break the loop
}
});
if (foundInstituteId) {
$('#edit-institute-id').val(foundInstituteId);
filterClients(foundInstituteId, $('#edit-client-id'), allEditClientOptions);
$('#edit-client-id').val(foundClientId);
}
// Set other fields
$('#edit-id').val(entryId);
// Handle date - ensure it's in correct format
let dateText = row.find('td:eq(5)').text().trim();
let dateText = row.find('td:eq(13)').text().trim();
if (dateText) {
$('#edit-date').val(dateText);
}
$('#edit-pressure').val(row.find('td:eq(3)').text().trim());
$('#edit-purity').val(row.find('td:eq(4)').text().trim());
$('#edit-notes').val(row.find('td:eq(6)').text().trim());
$('#edit-pressure').val(row.find('td:eq(4)').text().trim());
$('#edit-purity').val(row.find('td:eq(5)').text().trim());
$('#edit-druckkorrektur').val(row.find('td:eq(6)').text().trim());
$('#edit-lhe-zus').val(row.find('td:eq(11)').text().trim());
$('#edit-constant-300').val(row.find('td:eq(7)').text().trim());
$('#edit-korrig-druck').val(row.find('td:eq(8)').text().trim());
$('#edit-nm3').val(row.find('td:eq(9)').text().trim());
$('#edit-lhe').val(row.find('td:eq(10)').text().trim());
$('#edit-lhe-ges').val(row.find('td:eq(12)').text().trim());
$('#edit-popup-one').fadeIn();
});
// Update the save-edit-one handler
$('#save-edit-one').on('click', function() {
const clientId = $('#edit-client-id').val();
const instituteId = $('#edit-institute-id').val();
if (!instituteId) {
alert('Please select an institute');
return;
}
if (!clientId) {
alert('Please select a client');
return;
}
// Validate numbers
let pressure = parseFloat($('#edit-pressure').val());
let purity = parseFloat($('#edit-purity').val());
let druckkorrektur = parseFloat($('#edit-druckkorrektur').val()) || 1.0;
let lheZus = parseFloat($('#edit-lhe-zus').val()) || 0;
let gesFlaschInhalt = parseFloat($('#edit-constant-300').val()) || 300.0;
if (isNaN(pressure) || pressure < 0) {
alert('Please enter a valid pressure value');
return;
}
if (isNaN(purity) || purity < 0 || purity > 100) {
alert('Please enter a valid purity value (0-100)');
return;
}
if (isNaN(druckkorrektur) || druckkorrektur < 0) {
alert('Please enter a valid Druckkorrektur value');
return;
}
if (isNaN(lheZus) || lheZus < 0) {
alert('Please enter a valid L-He zus. value');
return;
}
// Calculate final values
calculateDerivedValues('edit');
const korrigDruck = parseFloat($('#edit-korrig-druck').val()) || 0;
const nm3 = parseFloat($('#edit-nm3').val()) || 0;
const lhe = parseFloat($('#edit-lhe').val()) || 0;
const lheGes = parseFloat($('#edit-lhe-ges').val()) || 0;
let formData = {
'id': $('#edit-id').val(),
'client_id': $('#edit-client-id').val(),
'date': $('#edit-date').val(), // Already in YYYY-MM-DD format
'pressure': $('#edit-pressure').val(),
'purity': $('#edit-purity').val(),
'notes': $('#edit-notes').val(),
'client_id': clientId,
'date': $('#edit-date').val(),
'pressure': pressure,
'purity': purity,
'druckkorrektur': druckkorrektur,
'lhe_zus': lheZus,
'constant_300': gesFlaschInhalt,
'korrig_druck': korrigDruck,
'nm3': nm3,
'lhe': lhe,
'lhe_ges': lheGes,
'csrfmiddlewaretoken': '{{ csrf_token }}'
};
@@ -362,14 +786,6 @@
alert('Please select a date');
return;
}
if (isNaN(formData.pressure) || formData.pressure < 0) {
alert('Please enter a valid pressure value');
return;
}
if (isNaN(formData.purity) || formData.purity < 0 || formData.purity > 100) {
alert('Please enter a valid purity value (0-100)');
return;
}
$.ajax({
url: '/update-entry/ExcelEntry/',
@@ -379,10 +795,16 @@
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.pressure);
row.find('td:eq(4)').text(response.purity);
row.find('td:eq(5)').text(response.date || '');
row.find('td:eq(6)').text(response.notes || '');
row.find('td:eq(4)').text(response.pressure);
row.find('td:eq(5)').text(response.purity);
row.find('td:eq(6)').text(response.druckkorrektur);
row.find('td:eq(7)').text(response.constant_300);
row.find('td:eq(8)').text(response.korrig_druck);
row.find('td:eq(9)').text(response.nm3);
row.find('td:eq(10)').text(response.lhe);
row.find('td:eq(11)').text(response.lhe_zus);
row.find('td:eq(12)').text(response.lhe_ges);
row.find('td:eq(13)').text(response.date || '');
$('#edit-popup-one').fadeOut();
} else {
alert('Error: ' + (response.message || 'Failed to update entry'));
@@ -424,4 +846,4 @@
</script>
</body>
</html>
</html>