diff --git a/budget.php b/budget.php index 73f7ac87..8c4b4ae2 100644 --- a/budget.php +++ b/budget.php @@ -1,154 +1,102 @@ - -
-
-

Budget

-
- -
+
+ +

Budget for

+
+
+
- -
- -
-
-
- -
- - -
-
-
-
-
-
-
" id="advancedFilter"> -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- -
-
- - "> - - - - - - - - - - - - - - - - - - - - - - + + +
YearMonthCategoryDescriptionAmountAction
- -
+ + + + + + + + + + + + + + $month): + $amount = getBudgetAmount($budgets, $category['category_id'], $index + 1); + $rowTotal += $amount; + $columnTotals[$index] += $amount; ?> - - -
ExpenseTotal
-
- -
+ + + + + + + + + Total + + + + + + + + + +
+
+ diff --git a/client_rack_unit_add_modal.php b/client_rack_unit_add_modal.php new file mode 100644 index 00000000..9a895850 --- /dev/null +++ b/client_rack_unit_add_modal.php @@ -0,0 +1,78 @@ + diff --git a/client_racks.php b/client_racks.php index 043125e1..c73e8dec 100644 --- a/client_racks.php +++ b/client_racks.php @@ -82,12 +82,34 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
-
-

U

+
+

U

+
- +
@@ -126,6 +148,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
+
diff --git a/plugins/php-imap/vendor/composer/autoload_files.php b/plugins/php-imap/vendor/composer/autoload_files.php index 38189e1f..45da959e 100644 --- a/plugins/php-imap/vendor/composer/autoload_files.php +++ b/plugins/php-imap/vendor/composer/autoload_files.php @@ -10,8 +10,8 @@ return array( '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', '662a729f963d39afe703c9d9b7ab4a8c' => $vendorDir . '/symfony/polyfill-php83/bootstrap.php', - 'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php', '2203a247e6fda86070a5e4e07aed533a' => $vendorDir . '/symfony/clock/Resources/now.php', + 'a1105708a18b76903365ca1c4aa61b02' => $vendorDir . '/symfony/translation/Resources/functions.php', '60799491728b879e74601d83e38b2cad' => $vendorDir . '/illuminate/collections/helpers.php', '72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php', '6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', diff --git a/plugins/php-imap/vendor/composer/autoload_psr4.php b/plugins/php-imap/vendor/composer/autoload_psr4.php index 058932b9..b6f82f5b 100644 --- a/plugins/php-imap/vendor/composer/autoload_psr4.php +++ b/plugins/php-imap/vendor/composer/autoload_psr4.php @@ -20,7 +20,7 @@ return array( 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), 'Psr\\Clock\\' => array($vendorDir . '/psr/clock/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), - 'Illuminate\\Support\\' => array($vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/support'), + 'Illuminate\\Support\\' => array($vendorDir . '/illuminate/collections', $vendorDir . '/illuminate/conditionable', $vendorDir . '/illuminate/macroable', $vendorDir . '/illuminate/support'), 'Illuminate\\Pagination\\' => array($vendorDir . '/illuminate/pagination'), 'Illuminate\\Contracts\\' => array($vendorDir . '/illuminate/contracts'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), diff --git a/plugins/php-imap/vendor/composer/autoload_static.php b/plugins/php-imap/vendor/composer/autoload_static.php index d5175505..586a0efc 100644 --- a/plugins/php-imap/vendor/composer/autoload_static.php +++ b/plugins/php-imap/vendor/composer/autoload_static.php @@ -11,8 +11,8 @@ class ComposerStaticInit58c0c92a2249336950aa4cce64d9be62 '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', '662a729f963d39afe703c9d9b7ab4a8c' => __DIR__ . '/..' . '/symfony/polyfill-php83/bootstrap.php', - 'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php', '2203a247e6fda86070a5e4e07aed533a' => __DIR__ . '/..' . '/symfony/clock/Resources/now.php', + 'a1105708a18b76903365ca1c4aa61b02' => __DIR__ . '/..' . '/symfony/translation/Resources/functions.php', '60799491728b879e74601d83e38b2cad' => __DIR__ . '/..' . '/illuminate/collections/helpers.php', '72579e7bd17821bb1321b87411366eae' => __DIR__ . '/..' . '/illuminate/support/helpers.php', '6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', @@ -126,9 +126,9 @@ class ComposerStaticInit58c0c92a2249336950aa4cce64d9be62 ), 'Illuminate\\Support\\' => array ( - 0 => __DIR__ . '/..' . '/illuminate/macroable', + 0 => __DIR__ . '/..' . '/illuminate/collections', 1 => __DIR__ . '/..' . '/illuminate/conditionable', - 2 => __DIR__ . '/..' . '/illuminate/collections', + 2 => __DIR__ . '/..' . '/illuminate/macroable', 3 => __DIR__ . '/..' . '/illuminate/support', ), 'Illuminate\\Pagination\\' => diff --git a/post/budget.php b/post/budget.php index 096a54ab..2b50fe9b 100644 --- a/post/budget.php +++ b/post/budget.php @@ -4,57 +4,48 @@ * ITFlow - GET/POST request handler for budget */ -if (isset($_POST['create_budget'])) { - - $month = intval($_POST['month']); +if (isset($_POST['save_budget'])) { + $budgets = $_POST['budget']; $year = intval($_POST['year']); - $amount = floatval($_POST['amount']); - $description = sanitizeInput($_POST['description']); - $category = intval($_POST['category']); + + foreach ($budgets as $category_id => $months) { + foreach ($months as $month => $amount) { + $amount = (int)$amount; + + // Check if budget exists + $query = "SELECT * FROM budget WHERE budget_category_id = $category_id AND budget_month = $month AND budget_year = $year"; + $result = mysqli_query($mysqli, $query); + if (mysqli_num_rows($result) > 0) { + // Update existing budget + $query = "UPDATE budget SET budget_amount = $amount WHERE budget_category_id = $category_id AND budget_month = $month AND budget_year = $year"; + } else { + // Insert new budget + $query = "INSERT INTO budget SET budget_category_id = $category_id, budget_month = $month, budget_year = $year, budget_amount = $amount"; + } + mysqli_query($mysqli, $query); + } + } + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Budget', log_action = 'Edit', log_description = '$session_name updated the budget for $year', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); + + $_SESSION['alert_message'] = "Budget Updated for $year"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); - mysqli_query($mysqli,"INSERT INTO budget SET budget_month = $month, budget_year = $year, budget_amount = $amount, budget_description = '$description', budget_category_id = $category"); - - $budget_id = mysqli_insert_id($mysqli); - - //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Budget', log_action = 'Create', log_description = '$description', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); - - $_SESSION['alert_message'] = "Budget created"; - - header("Location: " . $_SERVER["HTTP_REFERER"]); - + exit; } -if (isset($_POST['edit_budget'])) { - - $budget_id = intval($_POST['budget_id']); - $month = intval($_POST['month']); +if (isset($_POST['delete_budget'])) { $year = intval($_POST['year']); - $amount = floatval($_POST['amount']); - $description = sanitizeInput($_POST['description']); - $category = intval($_POST['category']); - mysqli_query($mysqli,"UPDATE budget SET budget_month = $month, budget_year = $year, budget_amount = $amount, budget_description = '$description', budget_category_id = $category WHERE budget_id = $budget_id"); + mysqli_query($mysqli,"DELETE FROM budget WHERE budget_year = $year"); //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Budget', log_action = 'Edit', log_description = '$description', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); - - $_SESSION['alert_message'] = "Budget edited"; - - header("Location: " . $_SERVER["HTTP_REFERER"]); - -} - -if (isset($_GET['delete_budget'])) { - $budget_id = intval($_GET['delete_budget']); - - mysqli_query($mysqli,"DELETE FROM budget WHERE budget_id = $budget_id"); - - //Logging - mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Budget', log_action = 'Delete', log_description = '$budget_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Budget', log_action = 'Delete', log_description = '$session_name deleted the budget for $year', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id"); $_SESSION['alert_type'] = "error"; - $_SESSION['alert_message'] = "Budget deleted"; + $_SESSION['alert_message'] = "Budget deleted for $year"; header("Location: " . $_SERVER["HTTP_REFERER"]); diff --git a/post/rack.php b/post/rack.php index 940df153..ddc09777 100644 --- a/post/rack.php +++ b/post/rack.php @@ -168,3 +168,75 @@ if (isset($_GET['delete_rack'])) { header("Location: " . $_SERVER["HTTP_REFERER"]); } + +if (isset($_POST['add_rack_unit'])) { + + validateTechRole(); + + $client_id = intval($_POST['client_id']); + $rack_id = intval($_POST['rack_id']); + $name = sanitizeInput($_POST['name']); + $unit_start = intval($_POST['unit_start']); + $unit_end = intval($_POST['unit_end']); + $asset = intval($_POST['asset']); + + mysqli_query($mysqli,"INSERT INTO rack_units SET unit_device = '$name', unit_asset_id = $asset, unit_start_number = $unit_start, unit_end_number = $unit_end, unit_rack_id = $rack_id"); + + $unit_id = mysqli_insert_id($mysqli); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Rack Unit', log_action = 'Create', log_description = '$session_name added a unit the rack', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $rack_id"); + + $_SESSION['alert_message'] = "Device Added to Unit $unit_start - $unit_end to rack"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if (isset($_POST['edit_rack_unit'])) { + + validateTechRole(); + + $unit_id = intval($_POST['unit_id']); + $client_id = intval($_POST['client_id']); + $rack_id = intval($_POST['rack_id']); + $name = sanitizeInput($_POST['name']); + $unit_start = intval($_POST['unit_start']); + $unit_end = intval($_POST['unit_end']); + $asset = intval($_POST['asset']); + + mysqli_query($mysqli,"UPDATE rack_units SET unit_device = '$name', unit_asset_id = $asset, unit_start_number = $unit_start, unit_end_number = $unit_end WHERE unit_id = $unit_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Rack Unit', log_action = 'Edit', log_description = '$session_name edited a unit on the rack', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $rack_id"); + + $_SESSION['alert_message'] = "Device edited on the rack"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if (isset($_GET['delete_rack_unit'])) { + + validateAdminRole(); + + $unit_id = intval($_GET['delete_rack_unit']); + + // Get Name and Client ID for logging and alert message + $sql = mysqli_query($mysqli,"SELECT rack_name, rack_id, rack_client_id FROM racks LEFT JOIN rack_units ON unit_rack_id = rack_id WHERE rack_id = $rack_id"); + $row = mysqli_fetch_array($sql); + $rack_name = sanitizeInput($row['rack_name']); + $client_id = intval($row['rack_client_id']); + $rack_id = intval($row['rack_id']); + + mysqli_query($mysqli,"DELETE FROM rack_unit WHERE unit_id = $unit_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Rack Unit', log_action = 'Delete', log_description = '$session_name removed device from rack', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $rack_id"); + + $_SESSION['alert_type'] = "error"; + $_SESSION['alert_message'] = "You removed device from the rack"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} \ No newline at end of file