mirror of
https://github.com/itflow-org/itflow
synced 2026-03-07 22:34:52 +00:00
Fix Creating Document from a template where is would not set the document_parent causing new documents to display revisions that dont exist
This commit is contained in:
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
<div class="modal-footer bg-white">
|
<div class="modal-footer bg-white">
|
||||||
|
|
||||||
<button type="submit" name="add_document_from_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create & edit</button>
|
<button type="submit" name="add_document_from_template" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Create</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>
|
||||||
|
|||||||
@@ -33,30 +33,6 @@ if (isset($_POST['add_document'])) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['add_document_template'])) {
|
|
||||||
|
|
||||||
validateTechRole();
|
|
||||||
|
|
||||||
$client_id = intval($_POST['client_id']);
|
|
||||||
$name = sanitizeInput($_POST['name']);
|
|
||||||
$description = sanitizeInput($_POST['description']);
|
|
||||||
$content = mysqli_real_escape_string($mysqli,$_POST['content']);
|
|
||||||
$content_raw = sanitizeInput($_POST['name'] . " " . str_replace("<", " <", $_POST['content']));
|
|
||||||
// Content Raw is used for FULL INDEX searching. Adding a space before HTML tags to allow spaces between newlines, bulletpoints, etc. for searching.
|
|
||||||
|
|
||||||
// Document add query
|
|
||||||
$add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_template = 1, document_folder_id = 0, document_created_by = $session_user_id, document_client_id = 0");
|
|
||||||
$document_id = mysqli_insert_id($mysqli);
|
|
||||||
|
|
||||||
// Logging
|
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document Template', log_action = 'Create', log_description = '$session_name created document template $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $document_id");
|
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Document template <strong>$name</strong> created";
|
|
||||||
|
|
||||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['add_document_from_template'])) {
|
if (isset($_POST['add_document_from_template'])) {
|
||||||
|
|
||||||
// ROLE Check
|
// ROLE Check
|
||||||
@@ -83,6 +59,9 @@ if (isset($_POST['add_document_from_template'])) {
|
|||||||
|
|
||||||
$document_id = mysqli_insert_id($mysqli);
|
$document_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
|
// Update field document_parent to be the same id as document ID as this is the only version of the document.
|
||||||
|
mysqli_query($mysqli,"UPDATE documents SET document_parent = $document_id WHERE document_id = $document_id");
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Create', log_description = 'Document $document_name created from template $document_template_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $document_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document', log_action = 'Create', log_description = 'Document $document_name created from template $document_template_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $document_id");
|
||||||
|
|
||||||
@@ -92,6 +71,30 @@ if (isset($_POST['add_document_from_template'])) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['add_document_template'])) {
|
||||||
|
|
||||||
|
validateTechRole();
|
||||||
|
|
||||||
|
$client_id = intval($_POST['client_id']);
|
||||||
|
$name = sanitizeInput($_POST['name']);
|
||||||
|
$description = sanitizeInput($_POST['description']);
|
||||||
|
$content = mysqli_real_escape_string($mysqli,$_POST['content']);
|
||||||
|
$content_raw = sanitizeInput($_POST['name'] . " " . str_replace("<", " <", $_POST['content']));
|
||||||
|
// Content Raw is used for FULL INDEX searching. Adding a space before HTML tags to allow spaces between newlines, bulletpoints, etc. for searching.
|
||||||
|
|
||||||
|
// Document add query
|
||||||
|
$add_document = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_template = 1, document_folder_id = 0, document_created_by = $session_user_id, document_client_id = 0");
|
||||||
|
$document_id = mysqli_insert_id($mysqli);
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Document Template', log_action = 'Create', log_description = '$session_name created document template $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $document_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Document template <strong>$name</strong> created";
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_POST['edit_document'])) {
|
if (isset($_POST['edit_document'])) {
|
||||||
|
|
||||||
validateTechRole();
|
validateTechRole();
|
||||||
|
|||||||
Reference in New Issue
Block a user