$name created"); redirect(); } if (isset($_POST['edit_category'])) { require_once 'category_model.php'; $category_id = intval($_POST['category_id']); mysqli_query($mysqli,"UPDATE categories SET category_name = '$name', category_type = '$type', category_color = '$color' WHERE category_id = $category_id"); logAction("Category", "Edit", "$session_name edited category $type $name", 0, $category_id); flash_alert("Category $type $name edited"); redirect(); } if (isset($_GET['archive_category'])) { $category_id = intval($_GET['archive_category']); // Get Category Name and Type for logging $sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id"); $row = mysqli_fetch_array($sql); $category_name = sanitizeInput($row['category_name']); $category_type = sanitizeInput($row['category_type']); mysqli_query($mysqli,"UPDATE categories SET category_archived_at = NOW() WHERE category_id = $category_id"); logAction("Category", "Archive", "$session_name archived category $category_type $category_name", 0, $category_id); flash_alert("Category $category_type $category_name archived", 'error'); redirect(); } if (isset($_GET['unarchive_category'])) { $category_id = intval($_GET['unarchive_category']); // Get Category Name and Type for logging $sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id"); $row = mysqli_fetch_array($sql); $category_name = sanitizeInput($row['category_name']); $category_type = sanitizeInput($row['category_type']); mysqli_query($mysqli,"UPDATE categories SET category_archived_at = NULL WHERE category_id = $category_id"); logAction("Category", "Unarchive", "$session_name unarchived category $category_type $category_name", 0, $category_id); flash_alert("Category $category_type $category_name unarchived"); redirect(); } if (isset($_GET['delete_category'])) { $category_id = intval($_GET['delete_category']); // Get Category Name and Type for logging $sql = mysqli_query($mysqli,"SELECT category_name, category_type FROM categories WHERE category_id = $category_id"); $row = mysqli_fetch_array($sql); $category_name = sanitizeInput($row['category_name']); $category_type = sanitizeInput($row['category_type']); mysqli_query($mysqli,"DELETE FROM categories WHERE category_id = $category_id"); logAction("Category", "Delete", "$session_name deleted category $category_type $category_name"); flash_alert("Category $category_type $category_name deleted", 'error'); redirect(); }