import xls update
This commit is contained in:
@@ -16,21 +16,28 @@ try {
|
||||
$start_column = trim($_POST['start_column']);
|
||||
$description = trim($_POST['description'] ?? '');
|
||||
$target_table = trim($_POST['target_table']);
|
||||
$client_specific_fields = trim($_POST['client_specific_fields'] ?? '{}'); // Recupera il JSON dei campi specifici
|
||||
|
||||
// Controllo sui campi obbligatori
|
||||
if (empty($id) || empty($name) || empty($header_row) || empty($start_column) || empty($target_table)) {
|
||||
throw new Exception("All fields marked with * are required.");
|
||||
}
|
||||
|
||||
// Validazione opzionale del JSON (per sicurezza)
|
||||
$decoded_fields = json_decode($client_specific_fields, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE && $client_specific_fields !== '{}') {
|
||||
throw new Exception("Invalid JSON format for client-specific fields.");
|
||||
}
|
||||
|
||||
// Connessione al database
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Aggiorna il database
|
||||
// Aggiorna il database, includendo client_specific_fields
|
||||
$stmt = $pdo->prepare("UPDATE excel_templates
|
||||
SET name = ?, header_row = ?, start_column = ?, description = ?, target_table = ?, updated_at = NOW()
|
||||
SET name = ?, header_row = ?, start_column = ?, description = ?, target_table = ?, client_specific_fields = ?, updated_at = NOW()
|
||||
WHERE id = ?");
|
||||
$stmt->execute([$name, $header_row, $start_column, $description, $target_table, $id]);
|
||||
$stmt->execute([$name, $header_row, $start_column, $description, $target_table, $client_specific_fields, $id]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$response["success"] = true;
|
||||
|
||||
Reference in New Issue
Block a user