31 lines
807 B
PHP
31 lines
807 B
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
require_once 'class/db-functions.php';
|
|
|
|
$response = ["success" => false, "message" => ""];
|
|
|
|
try {
|
|
if ($_SERVER["REQUEST_METHOD"] !== "POST") {
|
|
throw new Exception("Invalid request.");
|
|
}
|
|
|
|
$id = intval($_POST['id']);
|
|
$status = ($_POST['status'] === "active") ? "active" : "inactive";
|
|
|
|
$db = DBHandlerSelect::getInstance();
|
|
$pdo = $db->getConnection();
|
|
|
|
$stmt = $pdo->prepare("UPDATE excel_templates SET status = ?, updated_at = NOW() WHERE id = ?");
|
|
$stmt->execute([$status, $id]);
|
|
|
|
if ($stmt->rowCount() > 0) {
|
|
$response["success"] = true;
|
|
} else {
|
|
throw new Exception("Update failed.");
|
|
}
|
|
} catch (Exception $e) {
|
|
$response["message"] = $e->getMessage();
|
|
}
|
|
|
|
echo json_encode($response);
|