mirror of
https://github.com/itflow-org/itflow
synced 2026-03-21 21:15:38 +00:00
Updated Bulk Document Move to include the indented folder and sub folder structure
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content bg-dark">
|
<div class="modal-content bg-dark">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title"><i class="fa fa-fw fa-file-alt mr-2"></i>Moving documents</strong></h5>
|
<h5 class="modal-title"><i class="fa fa-fw fa-file-alt mr-2"></i>Moving documents</h5>
|
||||||
<button type="button" class="close text-white" data-dismiss="modal">
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
<span>×</span>
|
<span>×</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="modal-body bg-white">
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Move Document to</label>
|
<label>Move Documents to</label>
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
|
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
|
||||||
@@ -18,24 +18,69 @@
|
|||||||
<select class="form-control select2" name="bulk_folder_id">
|
<select class="form-control select2" name="bulk_folder_id">
|
||||||
<option value="0">/</option>
|
<option value="0">/</option>
|
||||||
<?php
|
<?php
|
||||||
$sql_folders_select = mysqli_query($mysqli, "SELECT * FROM folders WHERE folder_location = $folder_location AND folder_client_id = $client_id ORDER BY folder_name ASC");
|
// Fetch all folders for the client
|
||||||
while ($row = mysqli_fetch_array($sql_folders_select)) {
|
$sql_all_folders = mysqli_query($mysqli, "SELECT folder_id, folder_name, parent_folder FROM folders WHERE folder_client_id = $client_id ORDER BY folder_name ASC");
|
||||||
$folder_id_select = intval($row['folder_id']);
|
$folders = array();
|
||||||
$folder_name_select = nullable_htmlentities($row['folder_name']);
|
|
||||||
?>
|
// Build an associative array of folders indexed by folder_id
|
||||||
<option value="<?php echo $folder_id_select ?>"><?php echo $folder_name_select; ?></option>
|
while ($row = mysqli_fetch_assoc($sql_all_folders)) {
|
||||||
<?php
|
$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(' ', $level * 4);
|
||||||
|
|
||||||
|
echo "<option value=\"{$folder['folder_id']}\">$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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer bg-white">
|
<div class="modal-footer bg-white">
|
||||||
<button type="submit" name="bulk_move_document" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Move</button>
|
<button type="submit" name="bulk_move_document" 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>
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user