update insert and update XLS template fixed dropdown space

This commit is contained in:
2025-05-08 09:50:23 +02:00
parent d033024363
commit 7d0224ac19
3 changed files with 72 additions and 137 deletions
+32 -67
View File
@@ -71,62 +71,18 @@ if (json_last_error() !== JSON_ERROR_NONE) {
<?php include('include/topbar.php'); ?>
<div class="page-wrapper">
<div class="page-content">
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-4">
<div class="col">
<div class="card radius-10 border-start border-0 border-4 border-info">
<div class="card-body">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 text-secondary">Total Orders</p>
<h4 class="my-1 text-info">4805</h4>
<p class="mb-0 font-13">+2.5% from last week</p>
</div>
<div class="widgets-icons-2 rounded-circle bg-gradient-blues text-white ms-auto"><i class='bx bxs-cart'></i></div>
</div>
</div>
</div>
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">UpdateXLS Template</h5>
</div>
<div class="col">
<div class="card radius-10 border-start border-0 border-4 border-danger">
<div class="card-body">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 text-secondary">Total Revenue</p>
<h4 class="my-1 text-danger">$84,245</h4>
<p class="mb-0 font-13">+5.4% from last week</p>
</div>
<div class="widgets-icons-2 rounded-circle bg-gradient-burning text-white ms-auto"><i class='bx bxs-wallet'></i></div>
</div>
</div>
</div>
</div>
<div class="col">
<div class="card radius-10 border-start border-0 border-4 border-success">
<div class="card-body">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 text-secondary">Bounce Rate</p>
<h4 class="my-1 text-success">34.6%</h4>
<p class="mb-0 font-13">-4.5% from last week</p>
</div>
<div class="widgets-icons-2 rounded-circle bg-gradient-ohhappiness text-white ms-auto"><i class='bx bxs-bar-chart-alt-2'></i></div>
</div>
</div>
</div>
</div>
<div class="col">
<div class="card radius-10 border-start border-0 border-4 border-warning">
<div class="card-body">
<div class="d-flex align-items-center">
<div>
<p class="mb-0 text-secondary">Total Customers</p>
<h4 class="my-1 text-warning">8.4K</h4>
<p class="mb-0 font-13">+8.4% from last week</p>
</div>
<div class="widgets-icons-2 rounded-circle bg-gradient-orange text-white ms-auto"><i class='bx bxs-group'></i></div>
</div>
</div>
</div>
<div class="card-body">
<p class="mb-2">Edit the following form in order to update the selected import XLS template</p>
<p class="mb-2">Mandatory Fields</p>
<ul class="mb-0">
<li>Template Name</li>
<li>Row Header and Column Header: where the title of the excel starts</li>
<li>Destination Table: already prefilled</li>
</ul>
</div>
</div>
@@ -165,12 +121,24 @@ if (json_last_error() !== JSON_ERROR_NONE) {
<div class="mb-3">
<label class="form-label"><?= htmlspecialchars($desttable, ENT_QUOTES, 'UTF-8'); ?>*</label>
<input type="text" name="target_table" class="form-control" value="<?php echo htmlspecialchars($template['target_table']); ?>" required>
<input type="text" name="target_table" class="form-control" value="<?php echo htmlspecialchars($template['target_table']); ?>" readonly required>
</div>
<!-- Sezione per i campi specifici del cliente -->
<div class="mb-3">
<label class="form-label">Client-Specific Fields</label>
<!-- Intestazioni colonne -->
<div class="row fw-bold text-secondary mb-1">
<div class="col-md-3">Field Name</div>
<div class="col-md-2">Type</div>
<div class="col-md-2">Possible Values</div>
<div class="col-md-1">Required</div>
<div class="col-md-2">Export Column Name</div>
<div class="col-md-1">Default Value</div>
<div class="col-md-1">Actions</div>
</div>
<div id="clientSpecificFields">
<?php
$index = 0;
@@ -182,7 +150,6 @@ if (json_last_error() !== JSON_ERROR_NONE) {
$isRequired = isset($fieldData['is_required']) && $fieldData['is_required'] ? '1' : '0';
$exportColumnName = $fieldData['export_column_name'] ?? '';
$defaultValue = $fieldData['default_value'] ?? '';
error_log("Rendering field: $fieldName, type: $type, possible_values: $possibleValues, required: $isRequired, export: $exportColumnName, default: $defaultValue");
?>
<div class="client-field-row mb-2">
<div class="row align-items-center">
@@ -197,8 +164,8 @@ if (json_last_error() !== JSON_ERROR_NONE) {
<option value="boolean" <?php echo $type === 'boolean' ? 'selected' : ''; ?>>Yes/No</option>
</select>
</div>
<div class="col-md-2 dropdown-values" style="display: <?php echo $type === 'dropdown' ? 'block' : 'none'; ?>;">
<input type="text" name="specific_fields[<?php echo $index; ?>][possible_values]" class="form-control" value="<?php echo htmlspecialchars($possibleValues); ?>" placeholder="<?php echo !empty($fieldData['possible_values']) ? htmlspecialchars($possibleValues) : ''; ?>">
<div class="col-md-2 dropdown-values" style="<?php echo $type === 'dropdown' ? 'visibility: visible;' : 'visibility: hidden;'; ?>">
<input type="text" name="specific_fields[<?php echo $index; ?>][possible_values]" class="form-control" value="<?php echo htmlspecialchars($possibleValues); ?>" placeholder="Values (e.g., Red, Blue, Green)">
</div>
<div class="col-md-1">
<select name="specific_fields[<?php echo $index; ?>][required]" class="form-control">
@@ -219,18 +186,16 @@ if (json_last_error() !== JSON_ERROR_NONE) {
</div>
<?php
$index++;
} else {
error_log("Invalid field data for field name: $fieldName, skipping...");
}
}
} else {
error_log("No client-specific fields found or invalid array for template ID: $id");
}
?>
</div>
<button type="button" class="btn btn-primary mt-2" id="addField">Add Field</button>
</div>
<br>
<button type="submit" class="btn btn-primary"><?= htmlspecialchars($savechanges, ENT_QUOTES, 'UTF-8'); ?></button>
<a href="templates_dashboard.php" class="btn btn-secondary">Cancel</a>
@@ -347,8 +312,8 @@ if (json_last_error() !== JSON_ERROR_NONE) {
<option value="boolean">Yes/No</option>
</select>
</div>
<div class="col-md-2 d-none dropdown-values" style="display: none;">
<input type="text" name="specific_fields[${fieldCount}][possible_values]" class="form-control" placeholder="">
<div class="col-md-2 dropdown-values" style="visibility: hidden;">
<input type="text" name="specific_fields[${fieldCount}][possible_values]" class="form-control" placeholder="Values (e.g., Red, Blue, Green)">
</div>
<div class="col-md-1">
<select name="specific_fields[${fieldCount}][required]" class="form-control">
@@ -382,9 +347,9 @@ if (json_last_error() !== JSON_ERROR_NONE) {
const row = selectElement.closest(".row");
const dropdownValues = row.querySelector(".dropdown-values");
if (selectElement.value === "dropdown") {
dropdownValues.style.display = "block";
dropdownValues.style.visibility = "visible";
} else {
dropdownValues.style.display = "none";
dropdownValues.style.visibility = "hidden";
}
};