|
15 | 15 |
|
16 | 16 | // GET Software Info |
17 | 17 | $sql_software = mysqli_query($mysqli,"SELECT * FROM software WHERE software_id = $software_template_id"); |
18 | | - |
19 | 18 | $row = mysqli_fetch_array($sql_software); |
20 | | - |
21 | 19 | $name = sanitizeInput($row['software_name']); |
22 | 20 | $version = sanitizeInput($row['software_version']); |
23 | 21 | $description = sanitizeInput($row['software_description']); |
|
28 | 26 | // Software add query |
29 | 27 | 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_client_id = $client_id"); |
30 | 28 |
|
| 29 | + $software_id = mysqli_insert_id($mysqli); |
| 30 | + |
31 | 31 | // Logging |
32 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Create', log_description = 'Software created from template $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id"); |
| 32 | + logAction("Software", "Create", "$session_name created software $name using template", $client_id, $software_id); |
33 | 33 |
|
34 | | - $_SESSION['alert_message'] = "Software created from template"; |
| 34 | + $_SESSION['alert_message'] = "Software <strong>$name</strong> created from template"; |
35 | 35 |
|
36 | 36 | header("Location: " . $_SERVER["HTTP_REFERER"]); |
37 | 37 |
|
|
71 | 71 | $alert_extended = ""; |
72 | 72 |
|
73 | 73 | // Add Asset Licenses |
74 | | - if (!empty($_POST['assets'])) { |
| 74 | + if (isset($_POST['assets'])) { |
75 | 75 | foreach($_POST['assets'] as $asset) { |
76 | 76 | $asset_id = intval($asset); |
77 | 77 | mysqli_query($mysqli,"INSERT INTO software_assets SET software_id = $software_id, asset_id = $asset_id"); |
78 | 78 | } |
79 | 79 | } |
80 | 80 |
|
81 | 81 | // Add Contact Licenses |
82 | | - if (!empty($_POST['contacts'])) { |
| 82 | + if (isset($_POST['contacts'])) { |
83 | 83 | foreach($_POST['contacts'] as $contact) { |
84 | 84 | $contact = intval($contact); |
85 | 85 | mysqli_query($mysqli,"INSERT INTO software_contacts SET software_id = $software_id, contact_id = $contact"); |
86 | 86 | } |
87 | 87 | } |
88 | 88 |
|
89 | | - //Logging |
90 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Create', log_description = '$session_name created software $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $software_id"); |
| 89 | + // Logging |
| 90 | + logAction("Software", "Create", "$session_name created software $name", $client_id, $software_id); |
91 | 91 |
|
92 | 92 | $_SESSION['alert_message'] = "Software <strong>$name</strong> created $alert_extended"; |
93 | 93 |
|
|
128 | 128 |
|
129 | 129 | // Update Asset Licenses |
130 | 130 | mysqli_query($mysqli,"DELETE FROM software_assets WHERE software_id = $software_id"); |
131 | | - if (!empty($_POST['assets'])) { |
| 131 | + if (isset($_POST['assets'])) { |
132 | 132 | foreach($_POST['assets'] as $asset) { |
133 | 133 | $asset = intval($asset); |
134 | 134 | mysqli_query($mysqli,"INSERT INTO software_assets SET software_id = $software_id, asset_id = $asset"); |
|
137 | 137 |
|
138 | 138 | // Update Contact Licenses |
139 | 139 | mysqli_query($mysqli,"DELETE FROM software_contacts WHERE software_id = $software_id"); |
140 | | - if (!empty($_POST['contacts'])) { |
| 140 | + if (isset($_POST['contacts'])) { |
141 | 141 | foreach($_POST['contacts'] as $contact) { |
142 | 142 | $contact = intval($contact); |
143 | 143 | mysqli_query($mysqli,"INSERT INTO software_contacts SET software_id = $software_id, contact_id = $contact"); |
144 | 144 | } |
145 | 145 | } |
146 | 146 |
|
147 | | - //Logging |
148 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Modify', log_description = '$session_name modified software $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $software_id"); |
| 147 | + // Logging |
| 148 | + logAction("Software", "Edit", "$session_name edited software $name", $client_id, $software_id); |
149 | 149 |
|
150 | 150 | $_SESSION['alert_message'] = "Software <strong>$name</strong> updated"; |
151 | 151 |
|
|
171 | 171 | mysqli_query($mysqli,"DELETE FROM software_contacts WHERE software_id = $software_id"); |
172 | 172 | mysqli_query($mysqli,"DELETE FROM software_assets WHERE software_id = $software_id"); |
173 | 173 |
|
174 | | - //Logging |
175 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Archive', log_description = '$session_name archived software $software_name and removed all device/user license associations', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $software_id"); |
| 174 | + // Logging |
| 175 | + logAction("Software", "Archive", "$session_name archived software $software_name and removed all device/user license associations", $client_id, $software_id); |
176 | 176 |
|
177 | 177 | $_SESSION['alert_type'] = "error"; |
178 | 178 | $_SESSION['alert_message'] = "Software <strong>$software_name</strong> archived and removed all device/user license associations"; |
|
200 | 200 | mysqli_query($mysqli,"DELETE FROM software_assets WHERE software_id = $software_id"); |
201 | 201 |
|
202 | 202 | //Logging |
203 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Delete', log_description = '$session_name deleted software $software_name and removed all device/user license associations', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $software_id"); |
| 203 | + logAction("Software", "Delete", "$session_name deleted software $software_name and removed all device/user license associations", $client_id); |
204 | 204 |
|
205 | 205 | $_SESSION['alert_type'] = "error"; |
206 | 206 | $_SESSION['alert_message'] = "Software <strong>$software_name</strong> deleted and removed all device/user license associations"; |
|
278 | 278 | fpassthru($f); |
279 | 279 | } |
280 | 280 |
|
281 | | - // Logging |
282 | | - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Software', log_action = 'Export', log_description = '$session_name exported $num_rows software license(s) to a CSV file', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id"); |
| 281 | + //Logging |
| 282 | + logAction("Software", "Export", "$session_name exported $num_rows software(s) $software_name to a CSV file", $client_id); |
283 | 283 |
|
284 | 284 | exit; |
285 | 285 |
|
|
0 commit comments