Vendor templates stage 1: Admin > Vendor Templates rebuilt on the standard list with Active and Archived tabs, support line, hours and SLA, how many clients have a vendor from each, last used and changed by, sortable and searchable including by support line; new template page with what a vendor starts with, the clients with it and their account numbers, the license templates that use it, made and changed by, and history; shared New/Edit window on the vendor window's tabs with per-field push to the vendors made from it, each logged on the vendor; copy, archive, restore and delete with vendors and license templates unlinked on delete; Make a template from a client's vendor, linking the vendor to it, and the vendor page linking its template for admins; Delete offered to every admin role, not only the built-in Administrator; the admin handler no longer includes the agent vendor handler; database 3.3.4 adds vendor_template_created_by and vendor_template_updated_by, backfilled from the audit log

This commit is contained in:
johnnyq
2026-10-19 12:34:53 -04:00
parent a5a43e37ac
commit dfc708145d
36 changed files with 3514 additions and 780 deletions

View File

@@ -86,6 +86,9 @@ function logAudit($type, $action, $description, $client_id = 0, $entity_id = 0)
}
mysqli_query($mysqli, "INSERT INTO logs SET log_type = '$type', log_action = '$action', log_description = '$description', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $entity_id");
// On to a syslog server or SIEM, when that is set up (functions/log_forward.php)
logForwardQueue('audit', mysqli_insert_id($mysqli));
}
/*
@@ -164,11 +167,29 @@ function logHistory($status, $description, $invoice_id = 0, $quote_id = 0, $recu
mysqli_query($mysqli, "INSERT INTO history SET history_status = '$status', history_description = '$description', history_invoice_id = $invoice_id, history_quote_id = $quote_id, history_recurring_invoice_id = $recurring_invoice_id");
}
/*
* Writes an app log entry - what ITFlow itself does: cron runs, mail, payment
* providers, the API, errors (Admin > App Logs, functions/app_log.php).
* Unlike logAudit(), it takes plain text and escapes it here. $type is the
* level - info, warning, error or debug; anything else is put to the nearest,
* as the column takes only those.
*/
function logApp($category, $type, $details) {
global $mysqli;
$category = mysqli_real_escape_string($mysqli, substr($category, 0, 200));
$details = mysqli_real_escape_string($mysqli, substr($details, 0, 1000));
$type = strtolower(trim((string) $type));
if (!in_array($type, ['info', 'warning', 'error', 'debug'], true)) {
$type = in_array($type, ['critical', 'fatal', 'alert', 'emergency'], true) ? 'error' : ($type === 'warn' ? 'warning' : 'info');
}
mysqli_query($mysqli, "INSERT INTO app_logs SET app_log_category = '$category', app_log_type = '$type', app_log_details = '$details'");
// Cut by character, so a name or message with accents isn't cut through the middle of one
$category = mb_substr((string) $category, 0, 200);
$details = mb_substr((string) $details, 0, 1000);
$category_sql = mysqli_real_escape_string($mysqli, $category);
$details_sql = mysqli_real_escape_string($mysqli, $details);
mysqli_query($mysqli, "INSERT INTO app_logs SET app_log_category = '$category_sql', app_log_type = '$type', app_log_details = '$details_sql'");
// On to a syslog server or SIEM, from the level picked (functions/log_forward.php)
logForwardQueue('app', mysqli_insert_id($mysqli), $type, $category);
}