addition API BV
This commit is contained in:
@@ -19,6 +19,8 @@ try {
|
||||
$button_bg_color = trim($_POST['button_bg_color'] ?? '#007bff');
|
||||
$button_text_color = trim($_POST['button_text_color'] ?? '#ffffff');
|
||||
$button_label = trim($_POST['button_label'] ?? 'Click Me');
|
||||
$idclient = intval($_POST['client_id'] ?? 0); // Usa client_id dal form
|
||||
$clientname = trim($_POST['client_name'] ?? ''); // Usa client_name dal form
|
||||
$status = 'active'; // Default
|
||||
|
||||
// Recupera i client_specific_fields (JSON inviato dal form)
|
||||
@@ -34,18 +36,38 @@ try {
|
||||
throw new Exception("All fields marked with * are required.");
|
||||
}
|
||||
|
||||
// Validazione del idclient
|
||||
if ($idclient <= 0) {
|
||||
throw new Exception("Please select a valid client.");
|
||||
}
|
||||
|
||||
// Connessione al database
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Inserisci nel database, includendo client_specific_fields
|
||||
// Inserisci nel database, usando idclient e clientname
|
||||
$stmt = $pdo->prepare("INSERT INTO excel_templates
|
||||
(name, header_row, start_column, description, target_table, button_size, button_bg_color, button_text_color, button_label, status, client_specific_fields, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())");
|
||||
$stmt->execute([$name, $header_row, $start_column, $description, $target_table, $button_size, $button_bg_color, $button_text_color, $button_label, $status, $client_specific_fields]);
|
||||
(name, header_row, start_column, description, target_table, button_size, button_bg_color, button_text_color, button_label, idclient, clientname, status, client_specific_fields, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())");
|
||||
$stmt->execute([
|
||||
$name,
|
||||
$header_row,
|
||||
$start_column,
|
||||
$description,
|
||||
$target_table,
|
||||
$button_size,
|
||||
$button_bg_color,
|
||||
$button_text_color,
|
||||
$button_label,
|
||||
$idclient,
|
||||
$clientname,
|
||||
$status,
|
||||
$client_specific_fields
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$response["success"] = true;
|
||||
$response["message"] = "Template created successfully!";
|
||||
} else {
|
||||
throw new Exception("Failed to insert template.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user