mirror of
https://github.com/itflow-org/itflow
synced 2026-03-25 14:55:38 +00:00
You can now link files to documents
This commit is contained in:
@@ -61,6 +61,39 @@ $document_folder_id = intval($row['document_folder_id']);
|
|||||||
<button type="button" class="btn btn-secondary btn-block" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
|
<button type="button" class="btn btn-secondary btn-block" onclick="window.print();"><i class="fas fa-fw fa-print mr-2"></i>Print</button>
|
||||||
<hr>
|
<hr>
|
||||||
<h5>Related</h5>
|
<h5>Related</h5>
|
||||||
|
<h6>
|
||||||
|
<i class="fas fa-fw fa-paperclip text-secondary mr-2"></i>Files
|
||||||
|
<button type="button" class="btn btn-link btn-sm" data-toggle="modal" data-target="#linkFileToDocumentModal">
|
||||||
|
<i class="fas fa-fw fa-plus"></i>
|
||||||
|
</button>
|
||||||
|
</h6>
|
||||||
|
<ul>
|
||||||
|
<?php
|
||||||
|
$sql_files = mysqli_query($mysqli, "SELECT * FROM files, document_files
|
||||||
|
WHERE document_files.file_id = files.file_id
|
||||||
|
AND document_files.document_id = $document_id
|
||||||
|
ORDER BY file_name ASC"
|
||||||
|
);
|
||||||
|
|
||||||
|
$linked_files = array();
|
||||||
|
|
||||||
|
while ($row = mysqli_fetch_array($sql_files)) {
|
||||||
|
$file_id = intval($row['file_id']);
|
||||||
|
$file_name = nullable_htmlentities($row['file_name']);
|
||||||
|
|
||||||
|
$linked_files[] = $file_id;
|
||||||
|
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<?php echo $file_name; ?>
|
||||||
|
<a href="post.php?unlink_file_from_document&file_id=<?php echo $file_id; ?>&document_id=<?php echo $document_id; ?>">
|
||||||
|
<i class="fas fa-fw fa-times text-secondary ml-2"></i>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
<h6>
|
<h6>
|
||||||
<i class="fas fa-fw fa-users text-secondary mr-2"></i>Contacts
|
<i class="fas fa-fw fa-users text-secondary mr-2"></i>Contacts
|
||||||
<button type="button" class="btn btn-link btn-sm" data-toggle="modal" data-target="#linkContactToDocumentModal">
|
<button type="button" class="btn btn-link btn-sm" data-toggle="modal" data-target="#linkContactToDocumentModal">
|
||||||
|
|||||||
@@ -1323,11 +1323,19 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.1'");
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.1'");
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (CURRENT_DATABASE_VERSION == '0.8.1') {
|
if (CURRENT_DATABASE_VERSION == '0.8.1') {
|
||||||
//Insert queries here required to update to DB version 0.8.2
|
//Insert queries here required to update to DB version 0.8.2
|
||||||
|
mysqli_query($mysqli, "CREATE TABLE `document_files` (`document_id` int(11) NOT NULL,`file_id` int(11) NOT NULL, PRIMARY KEY (`document_id`,`file_id`))");
|
||||||
|
|
||||||
// Then, update the database to the next sequential version
|
// Then, update the database to the next sequential version
|
||||||
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.2'");
|
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.2'");
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (CURRENT_DATABASE_VERSION == '0.8.2') {
|
||||||
|
//Insert queries here required to update to DB version 0.8.3
|
||||||
|
|
||||||
|
// Then, update the database to the next sequential version
|
||||||
|
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.3'");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
* It is used in conjunction with database_updates.php
|
* It is used in conjunction with database_updates.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DEFINE("LATEST_DATABASE_VERSION", "0.8.1");
|
DEFINE("LATEST_DATABASE_VERSION", "0.8.2");
|
||||||
|
|||||||
@@ -132,6 +132,43 @@ if (isset($_POST['move_document'])) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['link_file_to_document'])) {
|
||||||
|
|
||||||
|
validateTechRole();
|
||||||
|
|
||||||
|
$client_id = intval($_POST['client_id']);
|
||||||
|
$document_id = intval($_POST['document_id']);
|
||||||
|
$file_id = intval($_POST['file_id']);
|
||||||
|
|
||||||
|
// Document add query
|
||||||
|
mysqli_query($mysqli,"INSERT INTO document_files SET file_id = $file_id, document_id = $document_id");
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Link', log_description = 'Created Document File link', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "File linked with Document";
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_GET['unlink_file_from_document'])) {
|
||||||
|
|
||||||
|
validateTechRole();
|
||||||
|
$file_id = intval($_GET['file_id']);
|
||||||
|
$document_id = intval($_GET['document_id']);
|
||||||
|
|
||||||
|
mysqli_query($mysqli,"DELETE FROM document_files WHERE file_id = $file_id AND document_id = $document_id");
|
||||||
|
|
||||||
|
//Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'unLink', log_description = 'Document File link removed', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "File has been unlinked";
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST['link_vendor_to_document'])) {
|
if (isset($_POST['link_vendor_to_document'])) {
|
||||||
|
|
||||||
validateTechRole();
|
validateTechRole();
|
||||||
|
|||||||
Reference in New Issue
Block a user