mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 10:54:52 +00:00
Migrated Vendor Templates to its own table, lots of code modifications here
This commit is contained in:
@@ -4,10 +4,6 @@
|
||||
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
|
||||
// Import shared code from software-side tickets as we reuse functions
|
||||
require_once 'post/user/software.php';
|
||||
|
||||
|
||||
if (isset($_POST['add_software_template'])) {
|
||||
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
@@ -17,12 +13,12 @@ if (isset($_POST['add_software_template'])) {
|
||||
$license_type = sanitizeInput($_POST['license_type']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_version = '$version', software_description = '$description', software_type = '$type', software_license_type = '$license_type', software_notes = '$notes', software_template = 1, software_client_id = 0");
|
||||
mysqli_query($mysqli,"INSERT INTO software_templates SET software_template_name = '$name', software_template_version = '$version', software_template_description = '$description', software_template_type = '$type', software_template_license_type = '$license_type', software_template_notes = '$notes'");
|
||||
|
||||
$software_id = mysqli_insert_id($mysqli);
|
||||
$software_template_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Logging
|
||||
logAction("Software Template", "Create", "$session_name created software template $name", 0, $software_id);
|
||||
logAction("Software Template", "Create", "$session_name created software template $name", 0, $software_template_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Software template <strong>$name</strong> created";
|
||||
|
||||
@@ -32,7 +28,7 @@ if (isset($_POST['add_software_template'])) {
|
||||
|
||||
if (isset($_POST['edit_software_template'])) {
|
||||
|
||||
$software_id = intval($_POST['software_id']);
|
||||
$software_template_id = intval($_POST['software_template_id']);
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
$version = sanitizeInput($_POST['version']);
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
@@ -40,13 +36,34 @@ if (isset($_POST['edit_software_template'])) {
|
||||
$license_type = sanitizeInput($_POST['license_type']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_description = '$description', software_type = '$type', software_license_type = '$license_type', software_notes = '$notes' WHERE software_id = $software_id");
|
||||
mysqli_query($mysqli,"UPDATE software_templates SET software_template_name = '$name', software_template_version = '$version', software_template_description = '$description', software_template_type = '$type', software_template_license_type = '$license_type', software_template_notes = '$notes' WHERE software_template_id = $software_template_id");
|
||||
|
||||
// Logging
|
||||
logAction("Software Template", "Edit", "$session_name edited software template $name", 0, $software_id);
|
||||
logAction("Software Template", "Edit", "$session_name edited software template $name", 0, $software_template_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Software template <strong>$name</strong> edited";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_software_template'])) {
|
||||
|
||||
$software_template_id = intval($_GET['delete_software_template']);
|
||||
|
||||
// Get Software Template Name for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT software_template_name FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$software_template_name = sanitizeInput($row['software_template_name']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
|
||||
//Logging
|
||||
logAction("Software Template", "Delete", "$session_name deleted software template $software_template_name");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Software Template <strong>$software_template_name</strong> deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user