function add_row($data, $type, $id, $first, $last) { $text = ''; if ($type == TYPE_CATEGORY) { $text .= '<div id="category_' . $id . '" class="category">'; } $class = $type == TYPE_RATE ? 'rate' : 'cat_title'; $tag = $type == TYPE_RATE ? 'id="' . $type . '_' . $id . '" ' : ''; $text .= '<div ' . $tag . 'class="' . $class . ' row flex">'; $text .= add_name($data, $type, $id); $text .= add_prices($data, $type, $id); $text .= add_tools($type, $first, $last); $text .= '</div>'; if ($type == TYPE_RATE && $last) { $ids = explode('_', $id); $text .= '<input id="nrate_' . $ids[0] . '" type="hidden" name="nrate_'; $text .= $ids[0] . '" value="' . (intval($ids[1]) + 1) . '" />'; $text .= '<div class="spacer"></div>'; $text .= '</div>'; } echo $text; }
} // If the order was updated if (isset($_POST['update_order'])) { foreach ($_POST['ids'] as $id) { $order = $_POST['order_' . $id]; update_project_order($order, $id); } // There is an alert message $alert = true; $alert_message = "The project order was updated successfully."; } // Check if a new project was submitted if (isset($_POST['add_project'])) { $name = $_POST['new_project']; // Insert a new project up to 100 chars add_name("projects", $name, 100); // Audit log $risk_id = 1000; $message = "A new project was added by the \"" . $_SESSION['user'] . "\" user."; write_log($risk_id, $_SESSION['uid'], $message); // There is an alert message $alert = true; $alert_message = "A new project was added successfully."; } // Check if a project was deleted if (isset($_POST['delete_project'])) { $value = (int) $_POST['projects']; // There is an alert message $alert = true; // Verify value is an integer if (is_int($value)) {
if (is_int($value)) { delete_value("planning_strategy", $value); // Audit log $risk_id = 1000; $message = "An existing planning strategy was removed by the \"" . $_SESSION['user'] . "\" user."; write_log($risk_id, $_SESSION['uid'], $message); // There is an alert message $alert = true; $alert_message = "An existing planning strategy was removed successfully."; } } // Check if a new close reason was submitted if (isset($_POST['add_close_reason'])) { $name = $_POST['new_close_reason']; // Insert a new close reason up to 50 chars add_name("close_reason", $name, 50); // Audit log $risk_id = 1000; $message = "A new close reason was added by the \"" . $_SESSION['user'] . "\" user."; write_log($risk_id, $_SESSION['uid'], $message); // There is an alert message $alert = true; $alert_message = "A new close reason was added successfully."; } // Check if a close reason was deleted if (isset($_POST['delete_close_reason'])) { $value = (int) $_POST['close_reason']; // Verify value is an integer if (is_int($value)) { delete_value("close_reason", $value); // Audit log