Updated All Exports to include your company name if exporting all and if exporting just from a client prepend the client name to file, introduced a sanitize_filename function and used it for the exports to always get a clean file name that works on every OS

This commit is contained in:
johnnyq
2025-09-10 12:50:10 -04:00
parent 23b2dcba70
commit 981fb9585d
18 changed files with 96 additions and 28 deletions

View File

@@ -204,16 +204,19 @@ if (isset($_GET['delete_software'])) {
}
if (isset($_POST['export_client_software_csv'])) {
if (isset($_POST['export_software_csv'])) {
enforceUserPermission('module_support');
if (isset($_POST['client_id'])) {
$client_id = intval($_POST['client_id']);
$client_query = "WHERE software_client_id = $client_id";
$client_name = getFieldById('clients', $client_id, 'client_name');
$file_name_prepend = "$client_name-";
} else {
$client_query = '';
$client_id = 0; //Logging
$file_name_prepend = "$session_company_name-";
}
$sql = mysqli_query($mysqli,"SELECT * FROM software $client_query ORDER BY software_name ASC");
@@ -224,7 +227,7 @@ if (isset($_POST['export_client_software_csv'])) {
$delimiter = ",";
$enclosure = '"';
$escape = '\\'; // backslash
$filename = "Software-" . date('Y-m-d') . ".csv";
$filename = sanitize_filename($file_name_prepend . "Software-" . date('Y-m-d_H-i-s') . ".csv");
//create a file pointer
$f = fopen('php://memory', 'w');