rename /user/ to /agent/ and update links to use agent/ instead

This commit is contained in:
johnnyq
2025-09-23 18:04:23 -04:00
parent 6b6c70f1df
commit edabc5c33f
373 changed files with 93 additions and 21 deletions

View File

@@ -0,0 +1,92 @@
<div class="modal" id="bulkMoveFilesModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-exchange-alt mr-2"></i>Bulk Moving Files</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Folder</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
</div>
<select class="form-control select2" name="bulk_folder_id">
<option value="0">/</option>
<?php
// Fetch all folders for the client
$sql_all_folders = mysqli_query($mysqli, "SELECT folder_id, folder_name, parent_folder FROM folders WHERE folder_location = 1 AND folder_client_id = $client_id ORDER BY folder_name ASC");
$folders = array();
// Build an associative array of folders indexed by folder_id
while ($row = mysqli_fetch_assoc($sql_all_folders)) {
$folders[$row['folder_id']] = array(
'folder_id' => intval($row['folder_id']),
'folder_name' => nullable_htmlentities($row['folder_name']),
'parent_folder' => intval($row['parent_folder']),
'children' => array()
);
}
// Build the folder hierarchy
foreach ($folders as $id => &$folder) {
if ($folder['parent_folder'] != 0 && isset($folders[$folder['parent_folder']])) {
$folders[$folder['parent_folder']]['children'][] = &$folder;
}
}
unset($folder); // Break the reference
// Prepare a list of root folders
$root_folders = array();
foreach ($folders as $id => $folder) {
if ($folder['parent_folder'] == 0) {
$root_folders[] = $folder;
}
}
// Display the folder options iteratively
$stack = array();
foreach (array_reverse($root_folders) as $folder) {
$stack[] = array('folder' => $folder, 'level' => 0);
}
while (!empty($stack)) {
$node = array_pop($stack);
$folder = $node['folder'];
$level = $node['level'];
// Indentation for subfolders
$indentation = str_repeat('&nbsp;', $level * 4);
// Check if this folder is selected
$selected = '';
if ($folder['folder_id'] == $get_folder_id) {
$selected = 'selected';
}
echo "<option value=\"{$folder['folder_id']}\" $selected>$indentation{$folder['folder_name']}</option>";
// Add children to the stack
if (!empty($folder['children'])) {
foreach (array_reverse($folder['children']) as $child_folder) {
$stack[] = array('folder' => $child_folder, 'level' => $level + 1);
}
}
}
?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="bulk_move_files" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Move</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,21 @@
<script src="js/file_delete_modal.js"></script>
<div class="modal" id="deleteFileModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="mb-4" style="text-align: center;">
<i class="far fa-10x fa-times-circle text-danger mb-3 mt-3"></i>
<h2>Are you sure?</h2>
<h6 class="mb-4 text-secondary">Do you really want to delete this file?</h6>
<h5 class="mb-4 text-secondary text-bold" id="file_delete_name">Name</h5>
<form action="post.php" method="POST">
<input type="hidden" name="file_id" id="file_delete_id" value="id">
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
<button type="button" name="cancel" class="btn btn-outline-secondary btn-lg px-5 mr-4" data-dismiss="modal">Cancel</button>
<input type="submit" name="delete_file" class="btn btn-danger btn-lg px-5" value="Yes, Delete!">
</form>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,75 @@
<div class="modal" id="linkAssetToFileModal<?php echo $file_id; ?>" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-desktop mr-2"></i>Link Asset to <strong><?php echo $file_name; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="file_id" value="<?php echo $file_id; ?>">
<div class="modal-body">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-desktop"></i></span>
</div>
<select class="form-control select2" name="asset_id">
<option value="">- Select an Asset -</option>
<?php
$sql_assets_select = mysqli_query($mysqli, "SELECT * FROM assets
WHERE asset_client_id = $client_id
AND asset_archived_at IS NULL
ORDER BY asset_name ASC"
);
while ($row = mysqli_fetch_array($sql_assets_select)) {
$asset_id = intval($row['asset_id']);
$asset_name = nullable_htmlentities($row['asset_name']);
?>
<option value="<?php echo $asset_id ?>"><?php echo $asset_name; ?></option>
<?php
}
?>
</select>
</div>
</div>
<?php
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets, asset_files
WHERE assets.asset_id = asset_files.asset_id
AND asset_files.file_id = $file_id
ORDER BY asset_name ASC"
);
$linked_assets = array();
while ($row = mysqli_fetch_array($sql_assets)) {
$asset_id = intval($row['asset_id']);
$asset_name = nullable_htmlentities($row['asset_name']);
$linked_assets[] = $asset_id;
?>
<div class="ml-2">
<a href="asset_details.php?client_id=<?php echo $client_id; ?>&asset_id=<?php echo $asset_id; ?>" target="_blank"><?php echo $asset_name; ?></a>
<a class="confirm-link float-right" href="post.php?unlink_asset_from_file&asset_id=<?php echo $asset_id; ?>&file_id=<?php echo $file_id; ?>">
<i class="fas fa-fw fa-trash-alt text-secondary"></i>
</a>
</div>
<?php
}
?>
</div>
<div class="modal-footer">
<button type="submit" name="link_asset_to_file" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Link</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>

View File

@@ -0,0 +1,132 @@
<?php
require_once '../../../includes/modal_header.php';
$file_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM files WHERE file_id = $file_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$client_id = intval($row['file_client_id']);
$file_folder_id = nullable_htmlentities($row['file_folder_id']);
$file_name = nullable_htmlentities($row['file_name']);
$file_ext = nullable_htmlentities($row['file_ext']);
if ($file_ext == 'pdf') {
$file_icon = "file-pdf";
} elseif ($file_ext == 'gz' || $file_ext == 'tar' || $file_ext == 'zip' || $file_ext == '7z' || $file_ext == 'rar') {
$file_icon = "file-archive";
} elseif ($file_ext == 'txt' || $file_ext == 'md') {
$file_icon = "file-alt";
} elseif ($file_ext == 'msg') {
$file_icon = "envelope";
} elseif ($file_ext == 'doc' || $file_ext == 'docx' || $file_ext == 'odt') {
$file_icon = "file-word";
} elseif ($file_ext == 'xls' || $file_ext == 'xlsx' || $file_ext == 'ods') {
$file_icon = "file-excel";
} elseif ($file_ext == 'pptx' || $file_ext == 'odp') {
$file_icon = "file-powerpoint";
} elseif ($file_ext == 'mp3' || $file_ext == 'wav' || $file_ext == 'ogg') {
$file_icon = "file-audio";
} elseif ($file_ext == 'mov' || $file_ext == 'mp4' || $file_ext == 'av1') {
$file_icon = "file-video";
} elseif ($file_ext == 'jpg' || $file_ext == 'jpeg' || $file_ext == 'png' || $file_ext == 'gif' || $file_ext == 'webp' || $file_ext == 'bmp' || $file_ext == 'tif') {
$file_icon = "file-image";
} else {
$file_icon = "file";
}
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-<?php echo $file_icon; ?> mr-2"></i>Moving File: <strong><?php echo $file_name; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="file_id" value="<?php echo $file_id; ?>">
<div class="modal-body">
<div class="form-group">
<label>Move File to</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
</div>
<select class="form-control select2" name="folder_id">
<option value="0">/</option>
<?php
// Fetch all folders for the client
$sql_all_folders = mysqli_query($mysqli, "SELECT folder_id, folder_name, parent_folder FROM folders WHERE folder_location = 1 AND folder_client_id = $client_id ORDER BY folder_name ASC");
$folders = array();
// Build an associative array of folders indexed by folder_id
while ($row = mysqli_fetch_assoc($sql_all_folders)) {
$folders[$row['folder_id']] = array(
'folder_id' => intval($row['folder_id']),
'folder_name' => nullable_htmlentities($row['folder_name']),
'parent_folder' => intval($row['parent_folder']),
'children' => array()
);
}
// Build the folder hierarchy
foreach ($folders as $id => &$folder) {
if ($folder['parent_folder'] != 0 && isset($folders[$folder['parent_folder']])) {
$folders[$folder['parent_folder']]['children'][] = &$folder;
}
}
unset($folder); // Break the reference
// Prepare a list of root folders
$root_folders = array();
foreach ($folders as $id => $folder) {
if ($folder['parent_folder'] == 0) {
$root_folders[] = $folder;
}
}
// Display the folder options iteratively
$stack = array();
foreach (array_reverse($root_folders) as $folder) {
$stack[] = array('folder' => $folder, 'level' => 0);
}
while (!empty($stack)) {
$node = array_pop($stack);
$folder = $node['folder'];
$level = $node['level'];
// Indentation for subfolders
$indentation = str_repeat('&nbsp;', $level * 4);
// Check if this folder is selected
$selected = '';
if ($folder['folder_id'] == $file_folder_id) {
$selected = 'selected';
}
echo "<option value=\"{$folder['folder_id']}\" $selected>$indentation{$folder['folder_name']}</option>";
// Add children to the stack
if (!empty($folder['children'])) {
foreach (array_reverse($folder['children']) as $child_folder) {
$stack[] = array('folder' => $child_folder, 'level' => $level + 1);
}
}
}
?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="move_file" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Move</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -0,0 +1,79 @@
<?php
require_once '../../../includes/modal_header.php';
$file_id = intval($_GET['id']);
$sql = mysqli_query($mysqli, "SELECT * FROM files WHERE file_id = $file_id LIMIT 1");
$row = mysqli_fetch_array($sql);
$client_id = intval($row['file_client_id']);
$file_name = nullable_htmlentities($row['file_name']);
$file_description = nullable_htmlentities($row['file_description']);
$file_ext = nullable_htmlentities($row['file_description']);
if ($file_ext == 'pdf') {
$file_icon = "file-pdf";
} elseif ($file_ext == 'gz' || $file_ext == 'tar' || $file_ext == 'zip' || $file_ext == '7z' || $file_ext == 'rar') {
$file_icon = "file-archive";
} elseif ($file_ext == 'txt' || $file_ext == 'md') {
$file_icon = "file-alt";
} elseif ($file_ext == 'msg') {
$file_icon = "envelope";
} elseif ($file_ext == 'doc' || $file_ext == 'docx' || $file_ext == 'odt') {
$file_icon = "file-word";
} elseif ($file_ext == 'xls' || $file_ext == 'xlsx' || $file_ext == 'ods') {
$file_icon = "file-excel";
} elseif ($file_ext == 'pptx' || $file_ext == 'odp') {
$file_icon = "file-powerpoint";
} elseif ($file_ext == 'mp3' || $file_ext == 'wav' || $file_ext == 'ogg') {
$file_icon = "file-audio";
} elseif ($file_ext == 'mov' || $file_ext == 'mp4' || $file_ext == 'av1') {
$file_icon = "file-video";
} elseif ($file_ext == 'jpg' || $file_ext == 'jpeg' || $file_ext == 'png' || $file_ext == 'gif' || $file_ext == 'webp' || $file_ext == 'bmp' || $file_ext == 'tif') {
$file_icon = "file-image";
} else {
$file_icon = "file";
}
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-<?php echo $file_icon; ?> mr-2"></i>Renaming file: <strong><?php echo $file_name; ?></strong></h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="file_id" value="<?php echo $file_id; ?>">
<div class="modal-body">
<div class="form-group">
<label>File Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
</div>
<input type="text" class="form-control" name="file_name" placeholder="File Name" maxlength="200" value="<?php echo $file_name; ?>" required>
</div>
</div>
<div class="form-group">
<label>Description</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
</div>
<input type="text" class="form-control" name="file_description" placeholder="Description" maxlength="250" value="<?php echo $file_description; ?>">
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="rename_file" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Rename</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -0,0 +1,96 @@
<div class="modal" id="uploadFilesModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fa fa-fw fa-cloud-upload-alt mr-2"></i>Upload File(s)</h5>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<?php if (isset($_GET['contact_id'])) { ?>
<input type="hidden" name="contact" value="<?php echo intval($_GET['contact_id']); ?>">
<?php } ?>
<?php if (isset($_GET['asset_id'])) { ?>
<input type="hidden" name="asset" value="<?php echo intval($_GET['asset_id']); ?>">
<?php } ?>
<div class="modal-body">
<div class="form-group">
<label>Description</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
</div>
<input type="text" class="form-control" name="description" maxlength="250" placeholder="Description of the file(s)">
</div>
</div>
<div class="form-group mb-4">
<label>Folder</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
</div>
<select class="form-control select2" name="folder_id">
<option value="0">/</option>
<?php
// Start displaying folder options from the root (parent_folder = 0)
display_folder_options(0, $client_id, 1);
?>
</select>
</div>
</div>
<div class="form-group">
<input type="file" class="form-control-file" name="file[]" multiple id="fileInput" accept=".jpg, .jpeg, .gif, .png, .webp, .pdf, .txt, .md, .doc, .docx, .odt, .csv, .xls, .xlsx, .ods, .pptx, .odp, .zip, .tar, .gz, .msg, .json, .wav, .mp3, .ogg, .mov, .mp4, .av1, .ovpn, .cfg, .ps1, .vsdx, .drawio, .pfx, .unf, .key, .stk, .bat">
</div>
<small class="text-secondary">Up to 20 files can be uploaded at once by holding down CTRL and selecting files</small>
</div>
<div class="modal-footer">
<button type="submit" name="upload_files" class="btn btn-primary text-bold"><i class="fa fa-upload mr-2"></i>Upload</button>
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
</div>
</form>
</div>
</div>
</div>
<script>
const maxFiles = 20; // Set the maximum number of allowed files
const maxTotalSize = 500 * 1024 * 1024; // 500MB in bytes
const fileInput = document.getElementById('fileInput');
const uploadForm = document.getElementById('uploadForm');
fileInput.addEventListener('change', function () {
const totalSize = calculateTotalFileSize(fileInput.files);
if (fileInput.files.length > maxFiles || totalSize > maxTotalSize) {
alert(`You can only upload up to ${maxFiles} files at a time and the total file size must not exceed 500MB.`);
resetFileInput();
}
});
uploadForm.addEventListener('submit', function (event) {
const totalSize = calculateTotalFileSize(fileInput.files);
if (fileInput.files.length > maxFiles || totalSize > maxTotalSize) {
event.preventDefault();
alert(`You can only upload up to ${maxFiles} files at a time and the total file size must not exceed 500MB.`);
resetFileInput();
}
});
function calculateTotalFileSize(files) {
let totalSize = 0;
for (const file of files) {
totalSize += file.size;
}
return totalSize;
}
function resetFileInput() {
fileInput.value = ''; // Clear the selected files
}
</script>

View File

@@ -0,0 +1,25 @@
<div class="modal" id="viewFileModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content bg-dark text-white">
<div class="modal-header bg-dark">
<h6 class="modal-title" id="modalTitle"></h6>
<button type="button" class="close text-white" data-dismiss="modal">
<span>&times;</span>
</button>
</div>
<div class="position-relative text-center">
<!-- Left arrow -->
<button type="button" class="btn btn-dark position-absolute" style="left:10px; top:50%; transform:translateY(-50%);" onclick="prevFile()">
<i class="fas fa-chevron-left"></i>
</button>
<img id="modalImage" class="img-fluid my-3" src="" alt="">
<!-- Right arrow -->
<button type="button" class="btn btn-dark position-absolute" style="right:10px; top:50%; transform:translateY(-50%);" onclick="nextFile()">
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</div>
</div>